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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -