function Animal (name) { this.name = name; } Animal.prototype.eat = function(food) { console.log(this.name + '正在吃:' + food); }; function Cat(){ } Cat.prototype = new Animal(); Cat.prototype.name = 'cat'; let cat = new Cat(); console.log(cat.eat('fish'));