(__proto__ property refers to the actual prototype of an object.)
Object is a function (and also used as a constructor).
Since it is a function, it’s constructor should be Function.
So, if I wanted some property added to Object, I could add it to Function.prototype.
But, Function is an object and all objects inherit from Object in some way.
Is this actually a cyclic relation?
I read this in an MDN page :
(some function) ---> Function.prototype ---> Object.prototype ---> null
How can null be the __proto__ of Object? Isn’t it Function.prototype again?
After reading up on this, I think the diagram in this answer, answers the question.
Every object in Javascript is has a
__proto__property which is the same as it’s constructor’s prototype property.So, if a property of an object isn’t found, it looks it up in it’s
__proto__property and upwards like that, until it either finds it or reachesnull.Object.prototypeis THE end of the prototype chain, withObject.prototype.constructorbeingObject.The fact that
Objectis a function, would mean that,Object.__proto__isFunction.prototype(becauseObjectcould have been created asnew Function())but not that
Object.prototype.__proto__isFunction.prototype.So, the
__proto__chain goesFunction.prototype–>Object.prototype–>nullI hope I got it right.