I've been reading about javascript prototype chaining and, as I understood, there is one global Object.prototype
which is the base for other prototypes, such as Array.prototype
, which can be the base for another prototype. Just like inheritance in class-based OOP. That's fine.
Now, I want to check and compare prototypes of distinct objects. If Array
's prototype is based on Object.prototype
, I guess that something like Array.prototype.prototype
should be possible. But it's undefined:
> Array.prototype.prototype
undefined
And when I type __proto__
instead of prototype
, I get:
> Array.__proto__
[Function: Empty]
> Object.__proto__
[Function: Empty]
> Array.__proto__.__proto__
{}
(console output is taken from nodejs). I've got following questions:
- how can I access "parent prototype" of a prototype?
- what's the difference between
prototype
and__proto__
?