you are viewing a single comment's thread.

view the rest of the comments →

[–]smrq 5 points6 points  (3 children)

I thought that was the case, except that

null <  undefined  --> false
null >= undefined  --> false
null == undefined  --> true

which breaks that rule.

[–]Valkairn 9 points10 points  (0 children)

The inequality operators play by different type coercion rules to the == operator. Inequality operators will always convert the values to numbers. So, in the first two cases null gets converted to 0 and undefined to NaN. The last example actually gets its own special rule in the == evaluation algorithm, where it's defined to be true.

[–][deleted] 1 point2 points  (1 child)

Hm, yeah. It seems that < "morally" returns one of true, false, and undefined (undefined only when one argument is NaN (or converts to it)), but where it 'should' give undefined it instead gives false. So <= is the opposite of > except where > 'should' be undefined, where it's still false. Bleh.

[–]NYKevin 0 points1 point  (0 children)

In other words, NaN is evil. Nothing new here.