title: Why is null an object in Javascript?
body: <p>Is there some specific reason behind keeping null an object type in JavaScript? I have a lot of type-checking in my code and I would like to know the reason/explanation behind it, so I can clear out the confusion. Like </p>
  
  <pre><code>var bar = null;
  console.log(typeof bar === "object");  // logs true!
  </code></pre>
  
  <p>In this case, what if bar was a function variable that returns an 'object'? Desired behaviour is that it should return true, but it actually return false.</p>
  
  <pre><code>var bar = function(){return {foo : 'bar'}};
  console.log(typeof bar === "object");  // logs false!
  </code></pre>