According to ES5 section 11.9.3 it says that
If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
When I tried to compare
let a = null, b = null;
a == false; // false
b == false; // false
a == ""; // false
b == ""; // false
a == 0; // false
b == 0; // false
What I was expecting here, for a == false
returning false is, false
is coerced to Number which is 0
so the comparison will become a == 0
then for next coercion, which is of type null == 0
, null should get coerced to Number
which is 0
. So finally it should return true for 0 == 0
.
What I got from ES5 11.9.3 is
If x is null and y is undefined, return true.
If x is undefined and y is null, return true.
Mentioned about null and undefined.
The 10th point of the ES 11.9.3 section says that if your comparison doesn't come in above 9 criteria return false
.
Is my comparison returning false
from according to 10th point in ES5 11.9.3 or am I missing something here>