prototype的问题
function Animal(name) {
this.name = name;
}
Animal.prototype = {
weight: 0,
eat: function() {
alert( "Animal is eating!" );
}
}
function Mammal() {
this.name = "mammal";
}
Mammal.prototype = new Animal("animal");
function Horse( height, weight ) {
this.name = "horse";
this.height = height;
this.weight = weight;
}
Horse.prototype = new Mammal();
Horse.prototype.eat = function() {
alert( "Horse is eating grass!" );
}
var horse = new Horse( 100, 300 );
问题:
Horse.prototype===?为true
Mammal.prototype===?为true
Animal.prototype===?为true