Douglas Crockford, although he is one of the smartest guys, is not God - everything he says should not be blind. There is actually one situation where you would like to prefer wrappers against primitive types - if you want to pass values ββby reference.
Primitive values ββare always passed by value and objects by reference . Therefore, if for some reason you need to pass numbers by reference , then you can do this using Number objects. In fact, you cannot change the value of a number without losing the link (AFAIK), but you can add additional parameters as desired, as with any object - primitive numbers do not support something.
var nr1 = new Number(123), nr2 = nr1; // reference to nr1 nr1.name = "number"; //parameter "name" for nr1 is set AFTER the initialization of nr2 alert(nr2.name); // nr2 has the same parameter as nr1
source share