Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What benefit is created by having a hierarchy of comparison operators in which there is no actual way to compare two numbers for semantic (not numeric) equivalence?

If (NaN == NaN) == false, and (NaN === NaN) == false, how would you implement an isNaN() function? If your answer is 'depend on the VM', I find that a bit strange.



typeof(NaN) should still be 'number', which would identify it uniquely. The irony of the value "Not a Number" having type "Number" is not lost on me, however.


function isNaN(x) { return x != x; };




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: