亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - How to understand the difference between prototype and __proto__?
漂亮男人
漂亮男人 2017-06-30 09:59:49
0
5
1288

How to understand the difference between prototype and __proto__?

漂亮男人
漂亮男人

reply all(5)
迷茫

When the constructor accesses the prototype, it is usually accessed through prototype. For example, we add methods to the prototype

Person.prototype.getName = function() {}

When the instance out of new accesses the prototype, in some supported browsers

function Person() {}

var p1 = new Person();

p1.__proto__ === Person.prototype   // true

Conclusion: prototype is used as a constructor to access the prototype, and __proto__ is used as an instance to access the prototype. When their identities are different, even when a method calls both at the same time, different prototypes may be accessed.

給我你的懷抱

Every object has __proto__, and prototype only Function has;

漂亮男人

Maybe you can also check out these:

/a/11...

https://developer.mozilla.org...

https://developer.mozilla.org...

某草草

prototype is an attribute of the constructor, __proto__ is an attribute of the instance. The __proto__ attribute of an instance generated using a constructor will point to the object pointed to by the constructor's prototype attribute.

Well, that’s it.

伊謝爾倫

In terms of function:
prototype determines the default value of proto when an object is defined using a constructor or literal form

proto is the basis for js engine prototype chain search

So the key point is that when you want to change the search method of the prototype chain, you can change the prototype chain search method of all subsequent instantiated objects by changing the constructor prototype, and use proto to modify the prototype chain search of a single object.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template