Primitives
In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. There are 7 primitive data types: string, number, bigint, boolean, undefined, symbol, and null.
Autoboxing
Due to a feature known as "autoboxing", JavaScript primitives appear to have methods and properties. What actually happens is that a wrapper object associated with the primitive is automatically accessed instead. Except for null and undefined, all primitive values have object equivalents that wrap around the primitive values:
- String for the string primitive.
- Number for the number primitive.
- BigInt for the bigint primitive.
- Boolean for the boolean primitive.
- Symbol for the symbol primitive.
The wrapper's valueOf() method returns the primitive value.
Backlinks