两段小代码第一段:functionOuter(){this.a=1;}functionInner(){}varouter=newOuter();Inner.prototype=outer;varinner=newInner();inner.a+=1;console.log(inner.a,outer.a);第二段:functionOuter(){this.data={a:1};}functionInner(){}varouter=newOuter();Inner.prototype=outer;varinner=newInner();inner.data.a+=1;console.log(inner.data.a,outer.data.a);请问下为什么两段代码运行结果不一样呢?在第二段代码中,在inner中修改变量为何会影响到outer?
湖上湖
相关分类