class Animal{
constructor(name,color){
this.name=name;
this.color=color
}
eat(){
return this.name+'吃饭 '
}
}
// 原型方法继承
Animal.prototype.run=(x)=>{
return x+'跑的快'
}
let dog=new Animal("hh",'red')
console.log(dog)
console.log(dog.eat())
console.log(dog.run('hh'))
class Cat extends Animal{
constructor(name,color,sex){
// 属性继承
super(name,color)
this.sex=sex
}
eat(){
// 方法继承
return super.eat()
}
}
let cat = new Cat('xx','black','woman')
console.log(cat)
console.log(cat.eat())
console.log(cat.run('xx'))