SOURCE

function Parent(name) {
  this.name = name;
  this.color = ['red','green'];
}

function Child(name) {
  Parent.call(this, name); 
  this.getName = function(name) {
        return this.name;
  }
  //无法进行函数的复用,构造函数中的方法会存在于每一个生成的实例内,重复的挂载只会浪费资源。
}

let child = new Child('child');//创建实例,可以传参了-原型链继承就不行
console.log(child.name); // child
child.color.push('black','pink');
console.log(child.color);// ["red", "green", "black", "pink"]
console.log(child.getName());//child

let child2 = new Child('child2');
console.log(child2.name);// "child2"
console.log(child2.color);// ["red", "green"] //解决了color属性所有实例共享的问题
console.log(child2.getName());//child
console 命令行工具 X clear

                    
>
console