How to understand the constructor's prototype object attributes

function Person(name){
    this.name = name;
}

var lilei = new Person("Lilei");

lilei.constructor === Person; // true
lilei instanceof Person; // true
lilei instanceof lilei.constructor; // true
lilei instanceof Person.prototype.constructor; // true

 

The above code shows that: constructor properties of the prototype object point of the current instance of the object constructor. 

That, in fact, is the constructor property reflects the relationship between the object and the instance constructor is like children to do DNA testing, we can be detected by the current instance of the object constructor this property which constructor "students".

Guess you like

Origin www.cnblogs.com/aisowe/p/11671495.html