function Mammal(name) { this.name = name; this.offspring = []; } Mammal.prototype.haveABaby = function() { var newBaby = new Mammal('Baby ' + this.name); this.offspring.push(newBaby); return newBaby; } Mammal.prototype.toString = function() {return '[Mammal "' + this.name + '"]';} Cat.prototype = new Mammal(); Cat.prototype.constructor = Cat; function Cat(name) {this.name = name;} Cat.prototype.toString = function() { return '[Cat " ' + this.name + '"]'; } var someAnimal = new Mammal('Mr. Biggles'); var myPet = new Cat('Felix'); myPet.haveABaby();