[NaN].indexOf(NaN) === -1 VS Object.is(NaN, NaN)

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Jun 14 00:24:15 PDT 2012

Hello everybody,
    I am not sure about the status of this subject but I find quite
inconsistent the fact we cannot trust Array#indexOf when it comes to NaN
... I am updating my es6-collections shim accordingly with what Paul Millr
said: my shim does not consider NaN as a valid key, being unable to find a
match through indexOf, so each NaN key will result into a new one for both
Map and Set ( broken WeakMap too )

I wonder if in the next future Array#indexOf will use internally Object.is
to compare values or if I have to use my own function to loop over all
values and do this kind of comparison.

Any thought on this will be appreciated and apologies if this has been
discussed already ( so a quick answer on "how it's going to be" would be
more than enough )

Best Regards,
    Andrea Giammarchi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120614/9c8075bf/attachment-0001.html>

More information about the es-discuss mailing list