The type of null is "object"

One of the most bizarre language features of JavaScript (and consequently, of TypeScript as well) is the result of typeof null.

Loading TypeScript...

In the first implementation of JavaScript, JavaScript values were represented as a type tag and a value. The type tag for objects was 0. null was represented as the NULL pointer (0x00 in most platforms). Consequently, null had 0 as type tag, hence the "object" typeof return value.

Was this page helpful?