New JavaScript prototype changes constructor
问题 When you create an object with a constructor it has a constructor property pointing to the constructor function: var Foo = function(foo) { this.foo = foo; } var myFoo = new Foo(123); myFoo.constructor === Foo; // true After creating this object I can change Foo.prototype ... Foo.prototype.x = 'y'; ... or reassign a new prototype object: Foo.prototype = { num: 99 }; myFoo.constructor === Foo; // still true But if I create a new Foo object after assigning a new object to Foo.prototype its