primitive
A primitive is a value that isn’t an object, such as a string, a number, or undefined, so it has no properties of its own and can’t be changed after it’s created.
ECMA-262 defines seven primitive types: string, number, bigint, boolean, undefined, symbol, and null. Every other value, including arrays and functions, is an Object.
The typeof operator names the type of a primitive, with one exception. It returns "object" for null, a historical bug kept for compatibility.
Primitives are immutable. A method such as .toUpperCase() returns a new string instead of changing the original. A variable that holds a primitive can be reassigned, but the value itself stays the same. Assigning a primitive to another variable copies the value, so the two variables never affect each other.
Primitives still appear to have properties. When code reads .length from a string, JavaScript wraps the value in a temporary wrapper object, such as a String object, and looks the property up there. The values null and undefined have no wrapper, so reading a property from them throws a TypeError.
Example
Say a profile form keeps the saved user name and copies it into a draft that the form edits:
> const savedName = "ada";
undefined
> let draftName = savedName;
undefined
> draftName = draftName.toUpperCase();
'ADA'
> savedName
'ada'
> savedName[0] = "A";
'A'
> savedName.nickname = "Countess";
'Countess'
> savedName.nickname
undefined
> savedName
'ada'
> savedName.length
3
Assigning savedName to draftName copied the string, and .toUpperCase() produced a new string for the draft, so the saved name kept its value. The two writes to savedName went to throwaway wrapper objects. The REPL runs in sloppy mode, so they fail silently, and strict mode code throws a TypeError instead. Reading .length works because the wrapper exposes the string’s properties.
Related Resources
Course
JavaScript's Type System Under the Hood
Port a museum gallery's temperature display from Python to JavaScript, and learn how JavaScript turns objects into text and numbers, and how to take control of it with Symbol.toPrimitive.
For additional information on related topics, take a look at the following resources:
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Nov. 17, 2026