题解 | #寄生组合式继承#

寄生组合式继承

http://www.nowcoder.com/practice/dd8eb918b5d343cc8be77a69630f59bf

function Human(name) {
  this.name = name
  this.kingdom = 'animal'
  this.color = ['yellow', 'white', 'brown', 'black']
}
Human.prototype.getName = function(){
  return this.name;
}
function Chinese(name,age) {
  Human.call(this,name)
  this.color = 'yellow'
  this.age = age
}
function Mid(){}
Mid.prototype = Human.prototype;
Chinese.prototype = new Mid();
//Chinese.prototype = Object.create(Human.prototype);
Chinese.prototype.constructor = Chinese;
Chinese.prototype.getAge = function(){
  return this.age;
}  
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务