javascript - Unable to understand <x>.prototype.constructor? -
i have 2 classes car , maruti. when use inheritance assigning prototype of maruti new car object. why have set maruti.prototype.constructor maruti. shown in code below.
function car(){ } function maruti(){ } maruti.prototype = new car() maruti.prototype.constructor = maruti unable understand last line of code. can explain in detail?
if maruti inherit car using maruti.prototype = new car(), need reset constructor property class maruti using maruti.prototype.constructor=maruti;, otherwise instances of maruti have constructor of car.
Comments
Post a Comment