Object
is Eve, and Function
is Adam, Adam (Function
) uses his bone (Function.prototype
) to create Eve (Object
). Then who created Adam (Function
)? -- The Inventor of the JavaScript language :-).
According to utsaina's answer, I want to add more useful info.
The most surprising thing for me was discovering that Object.__proto__
points to Function.prototype
, instead of Object.prototype
, but I'm
sure there's a good reason for that :-)
It should NOT be. Object.__proto__
should NOT point to Object.prototype
. Instead, the instance of Object
o
, o.__proto__
should point to Object.prototype
.
(Forgive me for using the terms class
and instance
in JavaScript, but you know it :-)
I think the class Object
itself is an instance of Function
, that's why Object.__proto__ === Function.prototype
. Therefore: Object
is Eve, and Function
is Adam, Adam (Function
) uses his bone (Function.prototype
) to create Eve (Object
).
Furthermore, even the class Function
itself is an instance of Function
itself, that is Function.__proto__ === Function.prototype
, that's also why Function === Function.constructor
Further furthermore, the regular class Cat
is an instance of Function
, that is Cat.__proto__ === Function.prototype
.
The reason for the above is, when we create a class in JavaScript, actually, we are just creating a function, which should be an instance of Function
. Object
and Function
are just special, but they are still classes, while Cat
is a regular class.
As a matter of factor, in Google Chrome JavaScript engine, the following 4:
Function.prototype
Function.__proto__
Object.__proto__
Cat.__proto__
They are all ===
(absolutely equal) to the other 3, and their value is function Empty() {}
> Function.prototype
function Empty() {}
> Function.__proto__
function Empty() {}
> Object.__proto__
function Empty() {}
> Cat.__proto__
function Empty() {}
> Function.prototype === Function.__proto__
true
> Function.__proto__ === Object.__proto__
true
> Object.__proto__ === Cat.__proto__
true
OK. Then who creates the special function Empty() {}
(Function.prototype
)? Think about it :-)
newtoy.prototype
is not equal tonewtoy.constructor.prototype
and thereforenewtoy.constructor.prototype
will not have property calledrating
. Similarlynewtoy.constructor.prototype.constructor.property
will also not have property calledrating
. – bits Oct 9 '12 at 1:28newtoy.constructor.prototype
will have property called rating. Similarlynewtoy.constructor.prototype.constructor.property
will also have property called rating. – bits Mar 20 '13 at 0:11__proto__
Vs.prototype
in JavaScript and How does JavaScript.prototype
work? – Bergi Mar 15 '14 at 13:52