寄生组合继承 就是 组合继承 + 原型式继承 的结合体 js内部会把这个寄生组成封装成 extend
function Father(name) {
this.name = name
this.hbody = ['吃饭', '睡觉', '打豆豆']
}
Father.prototype.getName = function() {
console.log(this.name)
}
function Son(name, age) {
Father.call(this, name)
this.age = age
}
Son.prototype = Object.create(Father.prototype)
// 手动挂上构造器,指向自己的构造函数
Son.prototype.construtor = Son
let S = new Son('亚瑟', '22')
let F = new Father('李白')
console.log('寄生组合1', S)
console.log('寄生组合2', F)