A type label left over from JavaScript’s beginnings

JavaScript’s `typeof` operator is meant to give a quick label for a value’s kind. But `typeof null` returns `"object"`, even though `null` means “no value” and is not an object you can use.

The mismatch traces to JavaScript’s early implementation. Values were represented with compact type tags, and `null` was encoded in a way that made the type-checking logic classify it with objects. The result was a bug in the label, not a hidden property of `null`.

Why the quirk survived

Once developers began writing programs around that behavior, changing it became risky. Code might explicitly check whether `typeof value === "object"` and then rely on the result—including, accidentally, for `null`. Making the operator return a new label could alter how old programs behave.

JavaScript therefore keeps the odd result for compatibility. It is a small example of how a language’s early design choices can become permanent once enough software depends on them.

The practical check

When a program needs to know whether a value is specifically `null`, it should compare the value directly: `value === null`. That distinguishes `null` from actual objects without relying on `typeof`’s broad category. A familiar label can be misleading; in JavaScript, the safer question is often not “What type does this operator report?” but “What exact value am I checking?”