Rick Merrill <ri***********@gmail.comwrites:
i think i see your answer to the OP is correct,
but how do you explain the apparent contradiction
0 == ""
AND
0 == "0"
That's not a contradiction, that's just type conversion.
See section 11.8.5 of the emacascript 262 specs:
The Abstract Equality Comparison Algorithm
The comparison x == y, where x and y are values, produces true or
false. Such a comparison is performed as follows:
1. If Type(x) is different from Type(y), go to step 14.
[ snip ]
14. If x is null and y is undefined, return true.
15. If x is undefined and y is null, return true.
16. If Type(x) is Number and Type(y) is String,
return the result of the comparison x == ToNumber(y).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^
[ snip ]
ToNumber("0") and ToNumber("") both evaluate to 0.
--
Joost Diepenmaat | blog:
http://joost.zeekat.nl/ | work:
http://zeekat.nl/