为了账号安全,请及时绑定邮箱和手机立即绑定

javascript继承问题

javascript继承问题

GCT1015 2018-11-22 22:18:39
代码如下:        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属性应该也是被共用的呀,为什么不是呢?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 475 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号