使用寄生式组合继承
function super (Name){
this.name =Name;
this.sayName = function(){
console.log(this.name)
}
}
super.prototype.say = function(){
console.log(this.name)
}
function sub (Age){
super.call(this)
this.age = Age
}
sub.prototype =Object.create(super.prototype)
sub.prototype.constructor = sub;
复制代码