The function will create the prorotype attribute to point to the prototype object, so prototype is a function-specific attribute and all objects in chrome seem to have the _proro_ attribute, so what is _proto_ ? Pointer to prototype object? What about _proto_ in the prototype object? Please help me solve my doubts. Thank you
_proto_ is an attribute on the instance object. Let me show it to you according to the content written in the book:
There is a _proto_ pointer on the son instance. This pointer points to its prototype object, not the constructor. Therefore, there is a prototype chain search process. All instances can find the method attributes on the prototype through the prototype chain and share them. . The top of this prototype chain is Object. When searching for properties and f methods on an instance, the search order is as follows: instance ==> constructor ==> prototype object ==> Object.
Regarding whether the end is an Object, there is a special case. The newly added Object.create() method in ES5 can change it. Ignore this factor for the time being. In most cases, the end is an Object, so the instance can use toString( on Object. ), valueOf(), hasOwnProperty() and other methods.
It’s not a good explanation, I hope it helps! This part can be figured out by reading the content in the book, combining the code in the book and practicing. It is recommended to refer to all the contents in Chapter 6 of "Height 3 Edition".
Please refer to Chapter 6 of "Advanced Programming with JavaScript"
__proto__ is an attribute of an object, through which you can access the attributes of the prototype object. The process is like this, when we use the new operator to instantiate an object, such as
__proto__ is an attribute of an object,
prototype is an attribute of a function,
functions are also objects, and they also have __proto__
I feel like there is no answer to the above point, __proto__ is a line, the destination of this line is the Prototype object (prototype object), __proto__ is used to connect the object and its prototype
First of all, correct the error in the question's description: prototype is not a unique attribute of the function.
If you really want to understand this issue, please study the
原型链
related knowledge of js.As the friend above said, please refer to Chapter 6 of "Advanced Programming with JavaScript". After you have a basic understanding, it will be clearer to look at this picture.
You can probably think of it this way, it’s easier to understand, but it may not be deep enough, but this is the best way to understand it. You can think of the methods and properties of the function that you don’t want to expose to you as the data stored in the Prototype object. The function is like the race of a race. It's very powerful and has potential power, just like a Saiyaman. There are many things that you can't see directly. You can only force him out through certain methods. Okay, then __proto__ can do it and use him. You will understand. It turns out that I can destroy the earth. Hahahaha
@ Linshuizhaohua
As shown in the picture, does this mean that Object and Function are both top-level objects?
Thank you for your answers. After looking at Elevation 3, the function will create a prototype attribute pointing to the prototype object. prototype is indeed a unique attribute of the function. There will be a pointer to the prototype object [[prototype]] inside the instance. In Firefox Chrome Safari, every All objects support the _proto_ attribute, which should be the browser implementation of [[prototype]].
Each constructor has a prototype object. The prototype object contains a pointer to the constructor. The instance object contains an internal pointer to the prototype object. The relationship between the prototype and the instance forms a prototype chain. Inheritance mainly relies on the prototype chain to make the prototype object equal to an instance of another type. The prototype object will contain a pointer to another prototype, and the other prototype will contain a pointer to the constructor layer by layer. The default prototype of all functions is object. The instance will point to obj.prototype, and finally I understand why all values can use Object.prototype.toString.call(value) to determine the type.
Constructor <-------- Prototype object < -------- Instance pointer
"It seems that it makes sense to read more, read more newspapers, eat less snacks and sleep more"
"Do you have a girlfriend?"
" new GirlFriend"
"..."