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.
In case you want to get the primitive value from a wrapper object, you can do so by using the
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.