Original: https://www.cnblogs.com/codernie/p/9098184.html
--------------------------------------------------------------------------------
1. What is the prototype of the class?
??? In JavaScript, whenever we define a constructor, the JavaScript engine automatically adds a prototype (also known as a prototype) to the class.
? 2. The object's Proto What is it?
??? In JavaScript, whenever we create an object using new, the JavaScript engine automatically adds a __proto__ property to the object and points it to its class prototype
//code 3.2function human (name) {this.name = Name}console.log (human.prototype) var person_test1 = new Human ( ' Test1 ') var person_ Test2 = new Human ( ' Test2 ') Console.log (person_test1.__proto__) console.log (person_test2.__proto__) console.log (human.prototype = = = person_test1.__proto__) //Trueconsole.log (human.prototype = = = person_test2.__proto__) //true
We will find that Human.prototype is an object, the human class is instantiated object Person_test1, Person_test2 has a property __proto__ is also an object, And they are all equal to Human.prototype, and we know that the equivalence of reference types in JavaScript means that they are pointing to the same object . So we can conclude that the __proto__ property of any instantiated object points to the prototype of its class.
"Turn" JavaScript classes, prototypes, inherited understandings