In the last lecture, we briefly mentioned this abstract concept prototype, so in this lecture, we specifically look at in the end what is the prototype prototype prototype prototype chain and what is the problem we often encounter / __proto__ difference ...... blablaba
First of all, we need a clear concept:
Any one of the functions (including constructors) has a prototype property, the function prototype object point
Any one instantiated object constructor, has a __proto__ property, point prototype object constructor.
In other words:
Each constructor (constructor) has a prototype object (prototype),
Prototype object contains a pointer pointing to the constructor,
Examples of the (instance) all contain a pointer to the prototype object.
See here, is not there a little bit about ~ on the following codes:
-------------------------------------------------- -------- a dividing line, to meet the powerful army (#_ #) -------------------------- -------------------------------
function Father () { the this .property = to true ; } Father.prototype.getFatherValue = function () { return the this .property; } function Son () { the this .sonProperty = to false ; } // // inherited Father Son.prototype = new new Father (); // Son.prototype is rewritten, resulting in Son.prototype.constructor also be rewritten together Son.prototype.getSonVaule = function () { return the this .sonProperty; } var instance = new new Son(); alert(instance.getFatherValue());//true