I have two classes Car
and Maruti
. When i use inheritance by assigning the prototype of Maruti
to new Car
object. Why do i have to set the Maruti.prototype.constructor
to Maruti
. Shown in the code below.
function Car(){
}
function Maruti(){
}
Maruti.prototype = new Car()
Maruti.prototype.constructor = Maruti
Unable to understand the last line of the code. Can someone explain in detail?