Of the personal blog website welcome communication: firefly: https://blog.xkongkeji.com

A one-sentence illustration:The implicit stereotype of the instance object points to the stereotype object of the constructor

What is a prototype

  • Javascript only functions have prototype properties by default. Instances constructed by constructors have no extensions by default, unless the instance is manually extended (this is not Prototype, of course, just a property named prototype).

  • In JS, everything is an object. A method is an object, and its prototype is an object.

  • Prototype is a property of an object with a [[Construct]] inner method.

    Such as functions, methods on objects, classes in ES6. Note that the arrow function in ES6 has no [[Construct]] method and therefore no prototype property unless you add one to it.

What is a __proto__

  • __proto__ is the bridge between the two instances and the prototype, what we call the prototype chain, and __proto__ points to the constructor’s prototype. The function of proto__ is to create a chain of prototypes, through __proto, you can constantly find the so-called parent prototype.
  • Each object has a __proto__ attribute

What is a prototype chain

  • JavaScript can create an association between two objects using prototype and __proto__ so that one object can delegate to the other object’s properties and functions.
  • Such an association is a stereotype chain, a finite chain of objects that implements inheritance and shared properties.