In JavaScript, the only non-primitive data type is Object. Arrays, functions, dates, regular expressions, maps, sets and class instances are all kinds of objects. Everything else (Number, String, Boolean, Undefined, Null, BigInt and Symbol) is primitive.
The question usually appears in multiple-choice form. If the options include Array or Function, they count as non-primitive because they are objects.
A primitive is an immutable value with no properties or methods of its own. A non-primitive value is an object: a collection of properties that can change after creation.
| Aspect | Primitive | Non-primitive (object) |
|---|---|---|
| Types | Number, String, Boolean, Undefined, Null, BigInt, Symbol | Object and its built-ins |
| Mutable | No, the value cannot change | Yes, properties can change |
| Compared by | Value | Reference (identity) |
| Copied by | Value | Reference to the same object |
All of these are non-primitive:
typeof returns "function" for callable objects, but a function is still an object: it has properties and inherits from Object.prototype. Use Array.isArray() to tell an array from a plain object.
Primitive values can look like objects because the engine wraps them temporarily when you call a method, as in "abc".toUpperCase(). The wrapper is discarded afterwards, and the string itself stays a primitive.
Assigning a primitive copies the value. Assigning an object copies the reference, so both variables point to one object:
To make an independent copy, use a shallow copy such as { ...original } or [...list], or structuredClone(value) for a deep copy of plain data. structuredClone is available in current browsers and Node.js, and it throws on functions.
Many tutorials say primitives live on the stack and objects on the heap. That is a simplification: the language specification does not define where values are stored, and engines may keep small values in registers or inline in objects. The reliable rule is behavioural: primitives behave as immutable values, and objects behave as shared references.
Objects are mutable by default, but you can restrict that:
Object.freeze is shallow, so nested objects stay mutable unless you freeze them too. Using const only prevents reassigning the variable, not changing the object.
Because typeof reports "object" for most non-primitives, combine checks when you need to be precise:
This helper returns true for every non-primitive value and false for every primitive, which is exactly the split the question is about.
No. An array is an object with numeric keys and a length property, so it is non-primitive.
No. Functions are callable objects and can have properties, which is why they can be passed around like any other value.
Yes. typeof null === "object" is a historic quirk. null is a primitive value, and you should test it with value === null.
A string value is a primitive. A new String("abc") wrapper is an object, and you should avoid creating wrappers like that.
Object is the only non-primitive data type, and arrays, functions, dates, regex, maps and sets are objects.Array.isArray() and === null where typeof is ambiguous.structuredClone.