instance of
Tue Aug 24 2021 07:10:08 GMT+0000 (Coordinated Universal Time)
Saved by
@rushiithombre
#javascript
var color = "red";
var color2 = {};
color instanceof String // will return true
color2 instanceof Object // will return true
--------------------------------------------------------------------
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
content_copyCOPY
Comments