Using the javascript library underscore.js (v.1.3.1), I’ve reproduced the following on the mac in up-to-date Chrome (17.0.963.56) and in Firefox 7.0:
0 === -1 * 0
> true
_.isEqual(0, -1 * 0)
> false
This is surprising, at least to me. I expected that two values for which === is true would result in _.isEqual also being true.
What’s going on here? Thanks!
It has been put explicitly in the source:
In fact, JavaScript does interpret
0and-0differently, but you usually don’t see this because0 == -0and0 === -0. There are only a few ways to check for the difference.