javascript继承问题

代码如下:

        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属性应该也是被共用的呀,为什么不是呢?

GCT1015
浏览 477回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript