=== again (sorry)
Maciej Stachowiak
mjs at apple.com
Fri Oct 31 17:10:33 PDT 2008
On Oct 31, 2008, at 4:48 PM, Mark S. Miller wrote:
> According to the ES3.1 spec and the behavior of at least FF3.0.3
>
> [4, -0, 0, NaN, 8].indexOf(0); // yields 1
> [4, -0, 0, NaN, 8].indexOf(NaN); // yields -1
>
> This is because indexOf and lastIndexOf are specified in terms of ===
> rather than SameValue. Is there any reason not to consider this a bug
> that should be fixed? In ES-Harmony, we've agreed that Map lookup will
> be according to SameValue (i.e. Object.eq or Object.identical).
>
> The indexOf and lastIndexOf methods are new in ES3.1, and are the only
> methods in the entire spec that depend on ===. So it's not too late to
> fix this.
I think on its merits the change you suggest makes sense.
But indexOf and lastIndexOf have been implemented cross-non-IE browser
for some time, so there is some small risk they are being used in non-
IE code paths on dual code-path sites and therefore a risk that
content depends on the existing behavior.
It's probably worth doing some research to quantify the risk.
Regards,
Maciej
More information about the Es-discuss
mailing list