The == comparison operator doesn't check the types. null and undefined both return false . That's why your code is actually checking if false is equal to false . However their types are not equal.
Why null == false is false?
However, if you coerce null to a number it is coerced to +0 so +null == false actually returns true . null and undefined are equivalent in this case most likely because they are the only two elements in JS which cannot handle any sort of property access. (0). toString() === "0" but (null).
Does null == undefined?
It means null is equal to undefined but not identical. When we define a variable to undefined then we are trying to convey that the variable does not exist . When we define a variable to null then we are trying to convey that the variable is empty. understanding.