<script> // 1. 父类构造器 function Father(name) { this.name = name; this.list = [1, 2, 3]; this.say = function() { console.log('hello'); } } // Child的实例无法继承Father原型上的属性或方法 Father.prototype.aaa = function() { console.log('aaa'); } // 2. 子类 function Child(name) { // 3. 借用父类的构造器 Father.call(this, name); } // 4. 创建实例1 var child = new Child('小王'); // 5. 创建实例2 var child2 = new Child('小红'); child2.list.push(4); console.log('child2', child2.list); console.log('child', child.list); // 6. 缺点展示: 方法会创建很多遍 console.log(child.aaa); // undefined,方法只能定义在父类的构造函数里 console.log(child.say === child2.say); // false, 所以每个实例都会创建一遍方法</script>