SOURCE

function Animal(){
    this.colors = ['white','black']
    this.weight = 20
}
/*
Animal.prototype.getColor= function(){
    return this.colors
}*/

function Dog() {}
Dog.prototype = new Animal()

const dog1 = new Dog({name:'dog'})
dog1.colors.push('yellow')
console.log('dog1',dog1)

const dog2 = new Dog()
dog2.weight = 16
console.log('dog2',dog2)

/*原型链继承问题
 *原型中的引用类型会被所有实例共享
 子类在实例化的时候不能给父类构造参数传参
*/

console 命令行工具 X clear

                    
>
console