代码如下: function Father(){ this.name = true; this.array = []; } Father.prototype.getFatherValue = function(){ return this.property; } function Son(){ this.sonProperty = false; } //继承 Father Son.prototype = new Father(); var son1 = new Son(); var son2 = new Son();其中Father的array属性会被son1和son2共用,但是name属性不会被共用,我的理解是,son1和son2都会去Son.prototype找name属性,name属性应该也是被共用的呀,为什么不是呢?
添加回答
举报
0/150
提交
取消