Answers for "js instanceof"

1

instanceof

function Phone(serial, price, color){
  this.serial = serial;
  this.price = price;
  this.color = color;
}

let phone1 = new Phone('abc1', 200, 'red');
let phone2 = new Phone('abc2', 400, 'green');

//instanceof 
console.log(phone1 instanceof Phone) // true

//constructor
console.log(phone1.constructor === Phone) //true
Posted by: Guest on July-24-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language