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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter