Javascript Null Type

I found this in JS articles, but I can't find an explanation, can someone point out the direction or explain here?

typeof null; // object
null === Object; // false
+1
source share
2 answers

This is because it Objectis a function. Therefore, null is null, and Object is a function.

typeof null === 'object'
typeof Object === 'function'
0
source

MDN explains it this way:

A null value is a JavaScript literal representing a null value or an "empty" value, that is, there is no object value. This is one of the basic JavaScript values.

Null is a literal

Further on this page you will find the following:

typeof null        // object (bug in ECMAScript, should be null)
typeof undefined   // undefined
null === undefined // false
null  == undefined // true

Here is a code with this code showing the results (and the error was talking about this)

document.getElementById('test1').innerHTML = typeof null;
document.getElementById('test2').innerHTML = typeof undefined;
document.getElementById('test3').innerHTML = null === undefined;
document.getElementById('test4').innerHTML = null == undefined;
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>
<div id="test4"></div>
Run codeHide result
+1
source

All Articles