null

Contents

null#

null is the intentional absence of a value. typeof null is "object" — a historical bug locked in by the spec.

const v = null;
typeof v;             // "object"  (historical)
v === null;           // true

Null vs undefined: null is the value the operator wrote; undefined is what the runtime supplied when no value was written. Code is clearer when these stay distinct, but == null matches both in one expression.

x == null             // true for both null and undefined

References#

  • undefined for the default-value sibling.

  • Casting for == vs === coercion rules.