Number.prototype=
{
constructor:Number
min:10,
max:15
};
var obj=new Number();
alert(obj.min);
Here I have created a new prototype for the default Number
constructor.
Then a new instance of Number
is created and stored in obj
.
As I have created an instance after the prototype assignment I expect that obj.min
will return 10
but it's returning undefined
.
I assume that because the constructor property of newly created Number.prototype
points to the same Number
constructor then the instance obj
's [PROTOTYPE]
property points to newly created prototype.
I think the problem lies in the assumption and that the obj
's [PROTOTYPE]
property points to the the original default prototype.