题解 | #寄生组合式继承#
寄生组合式继承
https://www.nowcoder.com/practice/dd8eb918b5d343cc8be77a69630f59bf
只要懂寄生组合式继承的核心,做这道题就跟写hello world一样
function Human(name) {
this.name = name
this.kingdom = 'animal'
this.color = ['yellow', 'white', 'brown', 'black']
}
function Chinese(name, age) {
Human.call(this, name)
this.color = 'yellow'
this.age = age
}
Chinese.prototype.__proto__ = Human.prototype
Human.prototype.getName = function () {
return this.name
}
Chinese.prototype.getAge = function () {
return this.age
}

正浩创新EcoFlow公司福利 644人发布