function Animal () {
console.log('new Animal');
}
Animal.prototype.run = function () {
console.log('animal runing');
};
function Beaver () {
Animal.apply(this, arguments);
console.log('new Beaver');
}
Beaver.prototype = new Animal();
Beaver.prototype.constructor = Beaver;
Beaver.prototype.run = function () {
console.log('beaver runing');
};
function Deer () {
Animal.apply(this, arguments);
console.log('new Deer');
}
Deer.prototype = new Animal();
Deer.prototype.constructor = Deer;
Deer.prototype.run = function () {
console.log('deer runing');
};
var deer = new Deer();
var beaver = new Beaver();
deer.run();
beaver.run();