functionSuperType(){this.name='s;'this.colors=["red","blue","green"];}functionSubType(){}//inheritfromSuperTypeSubType.prototype=newSuperType();varinstance1=newSubType();varinstance2=newSubType();instance1.name='ssss';instance1.colors=["red","blue"];alert(instance1.colors);//"red,blue,green,black"alert(instance1.name);//"ssss"alert(instance2.colors);//"red,blue,green,black"alert(instance2.name);//"s"instance2.name为什么没有改变functionSuperType(){this.name='sdsd';this.colors=["red","blue","green"];}functionSubType(){//inheritfromSuperTypeSuperType.call(this);}varinstance1=newSubType();instance1.colors.name='aaaaaaa';instance1.colors.push("black");alert(instance1.colors);//"red,blue,green,black"alert(instance1.name);//"a"varinstance2=newSubType();instance2.colors.name='bbbbbbb';alert(instance2.colors);//"red,blue,green"alert(instance2.name);//"a"instance2.name和instance1.name都没有改变
小唯快跑啊
相关分类