I found a difference in the handling of
[1,2,3].slice(1, undefined)
between chrome (that returns [2,3]) and firefox (that returns []).
Both of course instead agree on [2, 3] as the value of
[1,2,3].slice(1)
and they also both agree on [] as the value of
[1,2,3].slice(1, null)
Which of the two is correct? Or may be this not clearly specified in the standard?
The specification says:
Which Firefox version are you using? Firefox 5 gives me correctly
[2, 3]. Update: Firefox 3.6 returns indeed an empty array.I don’t know what is wrong here, because if you call
slice()without a second parameter,endwill beundefinedtoo.Update:
After playing around a bit, it seems that an empty array is returned if the second parameter passed to
.slice()isNaN. Example (+undefinedreturns NaN):This is the same in Firefox and in Chrome.
Unfortunately, this is also not conform to the specification, as
ToInteger(NaN)[spec] should return0, so the the array should actually be sliced to the end.I don’t claim that this is the reason why it does not work properly in some Firefox versions, I don’t know the implementation.
Incident of minor disorientation… never mind.