Skip to content
UniCircle
EasyConceptualData types

null vs undefined

Question JS-TYP-002

What is the difference between null and undefined? Where does each one appear naturally?

Show the explanation

Model answer. Both mean "no value", but they are used differently:

  • `undefined` is what JavaScript gives you when something was never set: a declared but unassigned variable, a missing function argument, a missing object property, or a function that returns nothing.
  • `null` is a value you assign on purpose to say "intentionally empty", for example clearing a selected item.
JavaScript
let picked;            // undefined: never assigned
const user = { manager: null };   // null: we know there is no manager
user.phone;            // undefined: property does not exist

Quirks worth knowing:

  • typeof undefined is "undefined", but typeof null is "object", a historical bug kept for compatibility.
  • null == undefined is true, but null === undefined is false.
  • Default parameters apply only for undefined, not null: f(null) does not trigger function f(x = 5).
  • ?? (nullish coalescing) treats both as missing: value ?? 'none'.

Original UniCircle question. Last reviewed 22 Oct 2026.