function Sup(){ this.name = 'adc'; this.arr = [1,2,3]; } Sup.prototype.say = function(){ console.log(this.arr) } function Sub(){ Sup.call(this) } Sub.prototype = Sup.prototype var c1 = new Sub() var c2 = new Sub()
2 回答

喵喔喔
TA贡献1735条经验 获得超5个赞
引用问题
直接赋值Sub.prototype
和Sup.prototype
指向同一个内存地址
所有两者会相互影响 在Sub
中定义的原型方法Sup
也会有
一般这样:Sub.prototype = Object.create(Sup.prototype)
添加回答
举报
0/150
提交
取消