The Seven Primitive Types in JavaScript and What They Hold
JavaScript has seven primitive types, from undefined and null to bigint and symbol. See what each holds and why a primitive never changes.

A value in JavaScript is either a primitive or an object, and nearly every confusing behavior in the language, from === surprises to "why did my copy change", traces back to which of the two you hold. There are exactly seven primitives. Learning them as a list of seven and one rule, that they never change, removes a surprising amount of guesswork. This post goes through each type, what it is for and where it surprises people, on Node.js 24 and ES2026. The wider map of the type system is in the complete guide to JavaScript types and coercion, and this post is the starting point for it.
Here are the seven, with the literal that creates each and what typeof says.
const samples = [
undefined,
null,
true,
42,
"text",
9007199254740993n,
Symbol("id"),
];
for (const value of samples) {
console.log(typeof value);
}undefined
object
boolean
number
string
bigint
symbolSix names match their type, and null reports "object". That is a bug from the first version of the language that was never fixed because too much code depends on it. The post on typeof covers the history and the safe check.
What each primitive is for
undefined means no value has been assigned: a declared variable never set, a missing property, a function with no return. null is a value you assign deliberately to say "nothing here", which makes the two different in intent even though both mean absence. When each one appears is the next question most people have.
boolean is true or false. number is a 64-bit floating point value, the only numeric type for most of the language's history, which is why it holds both integers and fractions and why 0.1 + 0.2 misbehaves. bigint holds whole numbers of any size, written with an n suffix. string is a sequence of UTF-16 code units. symbol is a unique value, usually used as a property key that cannot collide with any other.
| Type | Example | Holds | Notable limit |
|---|---|---|---|
undefined | undefined | The absence of an assigned value | Not an error, only empty |
null | null | A deliberate empty value | typeof null is "object" |
boolean | true | Two values | Everything else converts to it in conditions |
number | 3.14 | A 64-bit float | Integers are exact only up to 2^53 |
bigint | 10n | An integer of any size | Cannot be mixed with number in arithmetic |
string | "hi" | UTF-16 text | Immutable |
symbol | Symbol("x") | A unique token | Cannot be converted to a string implicitly |
Two of those limits turn into error messages, and it helps to see them once.
try {
console.log(1n + 1);
} catch (error) {
console.log(error.message);
}
try {
console.log(Symbol("id") + "");
} catch (error) {
console.log(error.message);
}
console.log(String(Symbol("id")));Cannot mix BigInt and other types, use explicit conversions
Cannot convert a Symbol value to a string
Symbol(id)The language refuses to guess in both cases. Explicit conversion, String(symbol) or BigInt(1) + 1n, is allowed, and that is the pattern across the whole type system: implicit conversion where it is safe, an exception where it would hide a loss. Details are in the post on BigInt.
Primitives never change
Immutability is the property that defines the group. You cannot alter a primitive; you can only produce a different one. String methods look as if they edit, and they return a new string.
const word = "node";
const loud = word.toUpperCase();
console.log(word);
console.log(loud);
let count = 5;
let copy = count;
copy += 1;
console.log(count, copy);node
NODE
5 6word is unchanged after toUpperCase(). Assigning copy = count copied the value, so incrementing copy left count alone. There is nothing to share, because a primitive has no identity apart from its content. Objects behave the other way, and the post on primitives versus objects is the other half of this idea.
Trying to change a primitive in place fails quietly in sloppy mode and loudly in strict mode. ES modules are strict, so a file run as a module shows the error.
const name = "abc";
try {
name[0] = "X";
} catch (error) {
console.log(error.message);
}
try {
name.extra = 1;
} catch (error) {
console.log(error.message);
}
console.log(name);Cannot assign to read only property '0' of string 'abc'
Cannot create property 'extra' on string 'abc'
abcIn a script without "use strict", both assignments do nothing and raise no error, which is why the bug survives. Every modern toolchain emits strict mode, so the error is what you will meet.
How a primitive has methods
If primitives have no properties, how does "abc".length work? The engine wraps the primitive in a temporary object of the matching type, looks the property up on that object, and discards the object. The wrapper types are String, Number, Boolean, BigInt and Symbol.
const text = "abc";
console.log(text.length);
console.log(typeof text);
const boxed = new String("abc");
console.log(typeof boxed);
console.log(boxed === "abc");
console.log(boxed.valueOf() === "abc");3
string
object
false
trueThe explicit new String("abc") is a real object, so typeof says "object" and strict equality with the primitive fails. Nobody should write new String in application code. Calling String(value) without new converts and returns a primitive, and that is the form to use. Boxing a primitive for a method call is cheap and optimized by the engine, so there is no reason to avoid method calls on strings and numbers.
Comparing by value
Because a primitive is its content, two of them are equal when the content matches, with no concept of "the same one".
console.log("a" + "b" === "ab");
console.log(10 === 5 + 5);
console.log(Symbol("id") === Symbol("id"));
console.log({ id: 1 } === { id: 1 });true
true
false
falseSymbols are the one primitive where equal-looking values are different: each call to Symbol() makes a new unique value, and the description is a label for debugging only. Objects are never equal unless they are the same object, as covered in how equality works for objects and arrays.
Strings are sequences, not arrays
A string indexes like an array and reads like one, and it is not one. It has length and at() and iterates by code point, but it has no push, and each edit produces a new string. Building a large string by repeated concatenation in a loop is allowed and fast on modern engines, which use ropes internally, so the habit of collecting pieces in an array and joining is no longer required for speed. It remains good for readability when there are many parts.
The unit of length is the UTF-16 code unit, not the character a person sees, so an emoji counts as two. Strings in JavaScript are UTF-16 has the consequences.
Choosing between number and bigint
The two numeric primitives overlap on whole numbers, and the choice is practical. number is a double, so integers are exact up to 9,007,199,254,740,991, which Number.MAX_SAFE_INTEGER names. Past that, neighboring integers collapse into the same double. bigint has no such ceiling, at the price of a separate arithmetic that will not mix with number.
console.log(Number.MAX_SAFE_INTEGER);
console.log(9007199254740992 === 9007199254740993);
console.log(9007199254740992n === 9007199254740993n);
console.log(2n ** 70n);9007199254740991
true
false
1180591620717411303424nThe second line is the failure: as numbers, two different integers compare equal because the second cannot be represented. Use bigint for ids that exceed 2^53, as some databases and social platforms issue, and for exact integer arithmetic. Keep number for everything else, because JSON cannot carry a bigint, Math functions reject it, and mixing them throws. We ship ids over the safe limit as strings across a JSON boundary and convert at both ends. Note that console.log prints a bigint with its n suffix, which is a reminder that the value is not a plain number and will not serialize with JSON.stringify() without a custom replacer.
Where this model stops
The seven-and-one rule describes the language, not the machine. Engines store small integers, strings and object references in different ways and move values between them. You cannot observe that from JavaScript, and it is not worth designing around.
There is also one value that is neither: typeof reports "function" for callable objects, which is a fine distinction in the operator and not an eighth primitive. Functions are objects. And two proposals, records and tuples, would add immutable compound values compared by content, but they have not reached the language, so code that needs value equality for structures still compares fields or serializes them.
For a concrete next step, read the post on truthy and falsy values to see how each primitive behaves in a condition, and how type coercion works for the conversions between them.
The list is defined in the ECMAScript specification under ECMAScript language types, and MDN keeps a readable summary on the JavaScript data types and data structures page.


