Javascript Inheritance ; call and prototype
To implement inheritance in Javascript, one generally does the following 2 steps; Say I have a base class "Animal" var Animal = function(name){ this.name = name; } I now want to derive a sub class "Dog" from the same. So I would say var Dog = function(name) { Animal.call(this,name); } So I am calling my parent class constructor from my derived class constructor. The 2nd step is to set the prototype as follows; Dog.prototype = new Animal(); Now I can access any of the base "Animal" class properties from within my derived class Dog. So my question is why are these 2 steps necessary ? If we just