SOURCE

function Animal(name) {
    this.name = name;
}

Animal.prototype.play = function() {
    console.log(`${this.name} is playing`);
}

Animal.prototype.eat = function(food) {
    console.log(`${this.name} is eating ${food}`);
}


function Dog(name) {
    Animal.call(this, name);
    this.test = 'xxx';
}


Object.setPrototypeOf(Dog.prototype, Animal.prototype);


Dog.prototype.methods = function() {
    //
    console.log('child method');
}


const animal = new Animal('Animal');
animal.play();

const dog = new Dog(`dog`);
dog.play();
dog.eat();
dog.methods();
console 命令行工具 X clear

                    
>
console