Skip to content
UniCircle
EasyConceptualData types

Primitive vs reference types

Question JS-TYP-001

What are the primitive data types in JavaScript, and how do primitives differ from objects (reference types) when you copy or compare them?

Show the explanation

Model answer. There are seven primitives: string, number, bigint, boolean, undefined, null and symbol. Everything else (plain objects, arrays, functions, dates, maps) is an object.

  • Primitives are immutable and copied by value. let b = a copies the value, so changing b never affects a.
  • Objects are copied by reference. The variable holds a reference, so two variables can point at the same object:
JavaScript
const a = { score: 1 };
const b = a;
b.score = 2;
console.log(a.score); // 2: same object
  • Comparison: primitives compare by value ('hi' === 'hi' is true); objects compare by identity ({} === {} is false, because they are two different objects).

This matters when passing values to functions: a function can mutate an object you pass in, but it can never change a primitive argument as the caller sees it.

Original UniCircle question. Last reviewed 22 Oct 2026.