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
var bar = null;
console.log(typeof bar === "object"); // logs true!
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.
var bar = function(){return {foo : 'bar'}};
console.log(typeof bar === "object"); // logs false!