JS: null

By Xah Lee. Date: . Last updated: .

What is null

typeof null

typeof null return "object". (this is a historical bug. typeof null should return "null" )

typeof null === "object"

Why “typeof null” return "object"

typeof null return "object" is a historical implementation bug. Now we are stuck with it. See: [The history of “typeof null” By Dr Axel Rauschmayer. At http://www.2ality.com/2013/10/typeof-null.html , accessed on 2015-10-28 ]

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

// null.p = 4;
// TypeError: Cannot set property 'p' of null

[see Object Type]

What is the Use of null

There are 2 major uses of null.

JavaScript, Special Literals

BUY ΣJS JavaScript in Depth