a = new Number(12); a.constructor.prototype.isPrototypeOf(a) // prints 'true'
I'm not smart enough to tell you why I just know that the way it is. And yes, this is strange.
Now you can say: " 12 is a primitive, and new Number(12) is an object." But how do you explain this?
(12).toFixed(3); // "12.000"
Apparently, somewhere, JavaScript solves primitive power as well as being an object.
Why is there such a difference? How do you convert between two forms? How does this affect performance? All questions related to this question, to which I have no answer.
Halcyon
source share