Problem with using ‘new’ for Inheritance
Imagine you have the following block of code.
function Animal() {
this.offspring = [];
}
function Dog() {
}
Dog.prototype = new Animal();
Dog.prototype.constructor = Dog;
var d1 = new Dog();
var d2 = new Dog();
var pup = new Dog();
d1.offspring....
blog.adarshkonchady.com1 min read