Types#

JavaScript has seven primitive types and one composite. Values carry their type; variables do not. typeof x returns a string tag. The operator’s edge-case file is built around the coercion rules between these types.

For literals, see Syntax. For operators, see Operators.

The catalog#

Type

What it holds

undefined

The default value of an uninitialised binding.

null

The intentional absence of a value.

boolean

true or false.

number

Double-precision IEEE 754 float.

bigint

Arbitrary-precision integer (literal suffix n).

string

UTF-16 code units; immutable.

symbol

Unique, primitive identifier.

object

Everything else; plain objects, arrays, functions, dates, errors, maps, sets, classes, promises.

Primitives#

undefined

The default of an uninitialised binding.

undefined
null

The intentional absence of a value.

null
boolean

Truthiness rules and the falsy list.

boolean
number

IEEE 754 doubles; NaN, Infinity, Number.MAX_SAFE_INTEGER.

number
bigint

Arbitrary-precision integer; literal suffix n.

bigint
string

Immutable UTF-16 sequences; template literals, tagged templates.

string
symbol

Unique primitive identifiers; well-known protocols.

symbol

Composite#

object

Everything that is not a primitive: plain objects, arrays, functions, dates, errors.

object

Conversion#

Casting

Conversion between the primitive types and the == / === coercion contrast.

Casting

References#