Javascript: Why is a constructor's __proto__ property Empty() { }? -
Javascript: Why is a constructor's __proto__ property Empty() { }? -
this question has reply here:
what - function empty() - in javascript ? [duplicate] 1 replyi created simple constructor like:
function car() { this.notires = 5; }
car.__proto__
prints out empty() {}
what mean?
protoype property of every constructor object prototype of new instance. can define this.
car.prototype.name="audi"; car.prototype.model="a4";
making constructor not mean making prototype. prototypes used when want create instances pointeng same block eg.
function person(){ } person.prototype.name = "detailer"; person.prototype.age = 17; person.prototype.job ="developer" person.prototype.sayname = function(){ alert(this.name); }; var person1 = new person(); var person2 = new person(); person1.name = "lakshay"; alert(person1.name); //lakshay - instance alert(person2.name); //detailer - prototype
javascript
Comments
Post a Comment