The result mentioned above is the way it is, because the == operator does type coercion so that it can compare the two for their values. Thus when you do something like
On the other hand if you did
foo === null (Identity) which checks for both type and value the result will be false which is the correct result because there is a type mismatch between the two. foo's type is undefined while null is an object. You can check that for yourself via
A property that has no definition is undefined, which also means no value, no type and never been referenced before in the scope. On the other hand, null is where the property exists but it isn't known what its value is.