4 ms·
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 pro
by xnorswap 5y ago
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.
- leodriesch 5y agoI suppose this is because `NaN === NaN` is false. Comparison via `Object.is(NaN, NaN)` works as expected though.
- masklinn 5y agoI don't think that beats ["1", "7", "11"].map(parseInt) returning [1, NaN, 3]
- deleted 5y ago[deleted]