A primitive is a basic JavaScript value that has no properties or methods of its own. The ECMAScript specification defines the primitive types, and each one gets its own entry here: string, number, bigint, boolean, undefined, null, and symbol. Primitives are immutable and compare by value, so two strings with the same characters are equal.
The typeof operator returns the name of a primitive’s type, with one exception: typeof null returns "object".
Each entry in JavaScript Primitive Types shows the type’s typeof result and its literal syntax. It also explains how other values convert to the type and which surprises to watch for, such as 0.1 + 0.2 or NaN !== NaN. The entries are short, so they work as a quick check when a value in a code review behaves differently than expected.
The true and false literals and the typeof operator live in JavaScript Keywords. Concepts that cut across types, such as primitives, type coercion, and truthy and falsy values, live in the JavaScript Glossary. This area picks up the primitive types themselves.
Not sure which term you need? Describe what you’re trying to do, and Mentor AI will point you to the right entries.
bigintA primitive type for whole numbers of arbitrary size, written with an n suffix, added in ES2020, and kept separate from number in arithmetic.
booleanA primitive type for the logical values true and false, the result of comparisons and the target of truthy and falsy conversion.
nullA primitive type whose only value is null, the intentional absence of an object value, with typeof null returning “object” as a historical quirk.
numberA primitive type for integers and fractional values, stored as 64-bit IEEE 754 floating-point numbers, including NaN, Infinity, and -0.
stringA primitive type for text, stored as an immutable sequence of UTF-16 code units and written with quotes or backtick template literals.
symbolA primitive type for unique, immutable identifiers, used as property keys that never collide and as well-known hooks such as Symbol.iterator.
undefinedA primitive type for missing or unassigned values, whose only value, undefined, is named by a read-only global property rather than a keyword.
Get a JavaScript Cheat Sheet (PDF), a printable reference to variables, types, strings, arrays, objects, functions, classes, modules, and async basics: