javascript高级程序设计 p167 页说借用构造函数无法函数复用,而且在超类型的原型中定义的方法,对子类型不可见
1.为什么不能函数复用?下面代码不算复用吗?
function Super(name) {
this.name = name
this.say = function () {
console.log(this.name)
}
}
function Sub(name) {
Super.call(this, name)
}
var i1 = new Sub('sub1')
var i2 = new Sub('sub2')
i1.say()
i2.say()
2.在超类型的原型中定义的方法,对子类型不可见什么意思?