In JavaScript, why typeof null return object?

By Xah Lee. Date: .

Why “typeof null” return "object"

console.log(typeof null === "object");

typeof null return "object" is a historical implementation bug. Now we are stuck with it.

null is not a object, because It doesn't have the defining quality of JavaScript objects, namely, it's not a collection of key-and-value pairs; you cannot add properties to null.

/*
2026-06-30
trying to assign a property to null.
null is not a object, so it fails.
*/

try {
 null.p = 4;
} catch (xerror) {
 console.log(xerror);
}
// TypeError: Cannot set properties of null (setting 'p')

JavaScript null

JavaScript problems