Please note that for legacy reasons,
typeof null gives you
'object' (as opposed to
null is actually a primitive type.
- Passed by value;
- Compared by value;
- Copied by value.
This is in contrast to an object (which is mutable, and is passed, copied and compared by reference).
undefined) that wrap around the primitive values:
Stringfor the string primitive;
Numberfor the number primitive;
BigIntfor the bigint primitive;
Booleanfor the boolean primitive;
Symbolfor the symbol primitive.
- You call an object method on a primitive value (e.g.
- You pass primitive as the first argument to
Function.prototype.apply()in non-strict mode
In such cases, the wrapper object is thrown away once the operation is complete.
One way to manually convert a primitive to its object equivalent would be to do the following:
String('foobar'); Number(123); // ...
In case you want to get the primitive value from the wrapper object, you can do so by using the
Hope you found this post useful. It was published . Please show your love and support by sharing this post.