Do you ever type "prototype"? Do you ever type "prototype" in any language but JavaScript? How it differs from other languages accessing [[Prototype]] / class directly, not through constructor?
I've thought that's caused by prototype inheritance, but no io language [1] prototype based yet easy to understand. The only difference — it does not hide [[Prototype]]. I've redefined Object and Function to show how it works. You would get same result in "dead" files. REPL to make it easy to reproduce.
Imagine it is another language
object.private = function () { return 'hello' }
Object.shared = function () { return 'world' }
Object.constructor.static = function () { return '!' }
vs
object.private = function() { return 'hello' }
Object.prototype.shared = function () { return 'world' }
Object.static = function () { return '!' }
Can you see the difference? Or straight from io tutorial
Contact = (class {
constructor(name, address, city) {
this.name = name
this.address = address
this.city = city
}
}).prototype
holmes = new Contact.constructor("Holmes", "221B Baker St", "London")
Contact.fullAddress = function() {
return [this.name, this.address, this.city].join('\n')
}
holmes.fullAddress()
No "prototype" (except from class but it can be redefined).
> ... and that's not even what instanceof means.
Thank you, it should check [[Prototype]] not constructor
// Object instanceof Object
Object.constructor.__proto__ === Function
// Object instanceof Object
Object.constructor.__proto__.__proto__ === Object
// Function instanceof Function
Function.constructor.__proto__ === Function
// Function instanceof Object
Function.constructor.__proto__.__proto__ === Object
[1]
https://iolanguage.org/