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

My favourite JS WATism:

    let a = NaN;
    let b = null;
    [a,b].indexOf(a);
    [a,b].indexOf(b);

FYI Array.prototype.Includes was made to "fix" this problem.


I don't think that beats

    ["1", "7", "11"].map(parseInt)
returning

    [1, NaN, 3]


I suppose this is because `NaN === NaN` is false. Comparison via `Object.is(NaN, NaN)` works as expected though.


The opposite would lead to `(0 * Infinity) === ("foo" / 3)` to be true. I don't know which is better...


Indeed, and not just NaN === NaN is false but even NaN == NaN is false too.




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

Search: