History behind typeof null equals object.
- symbol (new in es6)
- Null and undefined
var u; typeof u; //undefined var a = "inder"; typeof a; // string var b = true; typeof b; //boolean
However if you run
typeof on a null value, it returns
object, something you won't expect from a primitive type.
var i = NULL; typeof i; //object
- 000 - object
- 001 - int
- 010 - double
- 100 - string
- 110 - boolean
- To define undefined they used a special number 2 -30
- To define null NULL pointer was used.
After the type tage folows the actual value.
typeof got confused between zeros of null pointer and 000 tag of object and thus the bug.
Why isn't this bug removed?