The upper part of the object graph is formed in such a way as to maintain the same consistency with the expectations set elsewhere in the specification.
Necessarily, a point appears where the usual relationships of objects cannot be used because you have "finished objects".
A basic understanding of JavaScript leads us to the fact that [[Prototype]]
of Object
is a property of the prototype function used to create a functional Object
.
We expect Function
be created using the Function function object, so ...
Object.__proto__ === Function.prototype
Since we are at the top of the object graph and want to maintain consistency in the expected behavior, we configure [[Prototype]]
of Function
as Function.prototype
.
Function.__proto__ === Function.prototype
Thus, Function instanceof Function === true
provided.
We can show that Function.prototype
is a special function object because:
Function.prototype.prototype === undefined
... and each user-defined function (except for the bold arrows) has an object in the prototype property.
Due to all of the above:
Object.__proto__ === Function.__proto__
This may seem odd, but, as noted earlier, in the upper part of the object’s graph we have a limited set of candidate objects that are pointed to.
TC-39 now needs to determine what was [[Prototype]]
[[Prototype]]
of Object
. In accordance with the foregoing, we know that [[Prototype]]
of Object
Function.prototype
.
In a sense, we are now higher than Function.prototype
in the object graph, so a special instance of Object
("prototype object") was selected for this value.
This means that the top of each prototype chain can be conveniently linked using Object.prototype
.
This, of course, also meets the desirable requirement that everything "be an object."
Object.__proto__.__proto__ === Object.prototype
At this point, we need to populate the object graph, so we set [[Prototype]]
of Object.prototype
to null
.
Object.__proto__.__proto__.__proto__ === null