jjzjj

Javascript : Modifying Prototype doesn't affect existing Instances

这个问题在这里已经有了答案:OverwritingandExtendingPrototype(1个回答)关闭5年前。我创建了原型(prototype)的2个实例,更改了原型(prototype)中的函数,更改反射(reflect)在两个实例中(很棒)。但是,当我通过删除该函数修改原型(prototype)时,该函数对于现有实例仍然存在。functionA(){this.name="cool";}A.prototype={howCool:function(){returnthis.name+"er";}};vara1=newA(),a2=newA();a1.name="hot";//li