Suppose we have this constructor:
var Foo = function(){
this.x = \"y\";
}
Foo
and Foo.prototype.constructor
ev
.prototype.constructor
is just a helper property so that the objects created can easily refer the constructor with this.constructor
, or as in your case i.constructor
.
Setting it arbitrarily to something else doesn't have any effect except on code that expects to get the constructor of an object with obj.constructor
:
if( obj.constructor === Foo ) {
//It's a Foo
}
So it's a good convention just to leave it be.
The es5shim relies on .constructor.prototype
to shim Object.getPrototypeOf