Primitive Types
There are 7 primitive types:
undefined
null
Boolean
Number
(double-precision 64-bit binary format IEEE 754)String
BigInt
Symbol
Primitive types are immutable.
We'll look at
undefined
andnull
when we cover nullability.BigInt
andSymbol
are less common.
Primitive values
We declare primitive types using... primitive values (i.e. literals).
Constructor functions
It's also possible to instantiate the built-in types using their constructors — however, this is relatively uncommon and not idiomatic for common usage.
Standard library methods
We use standard library methods for manipulating primitives. These are available as methods on each instance.
JavaScript uses autoboxing to make these methods available even on literal values.
Type casting
There are library methods for casting strings to numbers and vice versa: