typeof null is "object" because of a historical mistake that was never fixed. MDN's account of the first JavaScript implementation: values were a type tag plus a value, the tag for objects was 0, and null was the NULL pointer (0x00 on most platforms), so null carried the object tag. A change to make typeof null === "null" was proposed for ECMAScript as an opt-in, but was rejected.
Today it is simply specified behaviour. The typeof algorithm tests undefined first, then explicitly says "if value is null, return "object"", and only afterwards looks at strings, symbols, booleans, numbers and BigInts.
null is still a primitive: the Null type has exactly one value. It doesn't behave like an object. Reading a property throws a TypeError, null instanceof Object is false, and it has no wrapper.
Consequences for real code:
typeof value === 'object'istruefornull, arrays, dates and plain objects alike. To test for "a non-null object", writevalue !== null && typeof value === 'object'.- To test for
nullitself, usevalue === null. Don't usetypeof. nullas the end of the prototype chain is the one place the language itself produces it:Object.getPrototypeOf(Object.prototype)isnull.