Object.is()

Andreas Rossberg rossberg at google.com
Tue Jan 7 07:28:40 PST 2014


On 7 January 2014 15:28, Brendan Eich <brendan at mozilla.com> wrote:
> Andreas Rossberg wrote:
>>
>> On 23 December 2013 03:17, Alex Kocharin<alex at kocharin.ru>  wrote:
>>>
>>> >
>>> >  That's something I never really understood when I was reading ES5
>>> > spec, where -0 is a special case, and a sole reason why `x ===
>>> > Number(String(x))` is not true for all numbers.
>>
>> NaN is another special case. IEEE equality is just broken,
>
> ... in your hardware, all of it.
>
> Standards from the last days of Disco, like Disco, will never die.

Yes. Yet there is no reason why languages keep using it as the generic
equality on floats. It could be a separate operator. Especially since
comparing floats for equality is disadvised against anyway...

>>> >  Why isn't it stringified as "-0"? How did that happen? Do somebody
>>> > really check if something is less than zero using "-" in string
>>> > representation?
>>
>> Lacking true integers, that would break JavaScript's poor man's
>> emulation of arrays.
>
> C'mon, that's not the reason. Hardly anyone generates -0 as an index and
> expects it to index a[0] for some array a. Things to complain about! :-P

It's not all that difficult to accidentally create a -0 when you do
pure "integer" arithmetic with floats. I'm pretty sure it would be a
major pitfall. Wasn't that the reason why we changed Map?

/Andreas


More information about the es-discuss mailing list