第二天

原型链的继承

function Animal(name,color){
this.name=name
this.color=color
}
Animal.prototype.eat=function(){
 console.log(this.color+"的"+this.name+"run...")
}

function Dog(name,color){
Animal.call(this,name,color)
}
    Dog.prototype = Object.create(Animal.prototype);
    Dog.prototype.constructor = Dog;

 

}

posted @ 2017-05-26 00:11  变雅猫  阅读(90)  评论(0)    收藏  举报