Object is a function, don’t be misled by its name, so complete the form in your mind first
function Object () {
...
}
Any function (constructor) has a prototype, which is prototype. There is nothing special about prototype, it is just an object.
Object.prototype outputs “Object { ... }”, don’t be misled by this output and think that Object.prototype is itself. The "Object" in the output simply means that the value of Object.prototype "is an object of type "Object".
But at the same time, because function itself in JS is also an object, Object is not only a function, but also an object. All objects are "constructed" (initialized) based on a prototype.
When is Object constructed as an object?
A: When it is defined, that is:
function Object() {
...
}
At this time, the JS runtime constructs the function "object" (instance) of Object based on function () { [Native code] } as the prototype.
What is this function () { [Native code] }? It is the ancestor of all functions in JS.
Object.__proto__.__proto__ is the prototype of this ancestor function. Since it is an ancestor, how can it have a prototype? Remember that it is the ancestor of the function, but it is not the ancestor of the "object". The ancestor of the object is this "Object {__defineGetter__: ...}".
You asked again, since objects are constructed, then ancestor objects should also be constructed, right? The ancestor object is the origin of all things. It is defined by the language designer of JS and is the starting point of the conceptual system.
But I saw
Object.prototype.constructor
function Object() { [native code] }
The ancestor object is not clearly constructed? And it is constructed from Object?
This is just that the JS language designer pointed the constructor of the ancestor object to Object for the sake of conceptual consistency.
What was the ancestor object before?
Object.prototype.__proto__
null
Tao gives birth to one, and gives birth to two. The Tao is nothingness.
Object is a function, don’t be misled by its name, so complete the form in your mind first
Any function (constructor) has a prototype, which is prototype. There is nothing special about prototype, it is just an object.
Object.prototype outputs “Object { ... }”, don’t be misled by this output and think that Object.prototype is itself. The "Object" in the output simply means that the value of Object.prototype "is an object of type "Object".
But at the same time, because function itself in JS is also an object, Object is not only a function, but also an object. All objects are "constructed" (initialized) based on a prototype.
When is Object constructed as an object?
A: When it is defined, that is:
At this time, the JS runtime constructs the function "object" (instance) of Object based on function () { [Native code] } as the prototype.
What is this function () { [Native code] }? It is the ancestor of all functions in JS.
Object.__proto__.__proto__ is the prototype of this ancestor function. Since it is an ancestor, how can it have a prototype? Remember that it is the ancestor of the function, but it is not the ancestor of the "object". The ancestor of the object is this "Object {__defineGetter__: ...}".
You asked again, since objects are constructed, then ancestor objects should also be constructed, right? The ancestor object is the origin of all things. It is defined by the language designer of JS and is the starting point of the conceptual system.
But I saw
The ancestor object is not clearly constructed? And it is constructed from Object?
This is just that the JS language designer pointed the constructor of the ancestor object to Object for the sake of conceptual consistency.
What was the ancestor object before?
Tao gives birth to one, and gives birth to two.
The Tao is nothingness.
itlr.cc