<script>
// 1. 创建一个组合式继承
function Father(name, age) {
this.name = name;
this.age = age;
this.list = [1, 2, 3];
}
Father.prototype.say = function() {
console.log(this.name);
}
function Child(name, age) {
// 借用构造函数
Father.call(this, name, age);
}
// 2. 添加寄生式继承Object.create
Child.prototype = Object.create(Father.prototype);
// Child.prototype.__proto__ === Father.prototype; 产生原型的继承关系
console.log(Child.prototype.constructor === Child); // false, 因为寄生式继承破坏了原来的原型关系
// 3. 重新制定子类原型对象的构造函数
Child.prototype.constructor = Child;
var child = new Child('张三', 18);
console.log('child', child);
</script>