default `deleteCount` value of `Array.prototype.splice`

David Bruant bruant.d at gmail.com
Tue Jul 3 07:07:35 PDT 2012


Le 03/07/2012 15:09, John-David Dalton a écrit :
> Just checked and IE8 returns `[]` correctly weeee!
>
> On Tue, Jul 3, 2012 at 8:49 AM, John-David Dalton 
> <john.david.dalton at gmail.com <mailto:john.david.dalton at gmail.com>> wrote:
>
>     I recently saw something like
>
>     var a = ['a', 'b', 'c', 'd'];
>     a.splice(2); // -> ['c', 'd'] in latest Chrome, Opera, Firefox,
>     Safari, Rhino, RingoJS, you name it
>
>     by spec though I thought the `deleteCount` should be `0` and so
>     return `[]`.
>     http://es5.github.com/#x15.4.4.12
>
>     "Let /actualDeleteCount/ be min(max(ToInteger
>     <http://es5.github.com/#x9.4>(/deleteCount/),0),/len/ --/ actualStart/)."
>
>     var a = ['a', 'b', 'c', 'd'];
>     a.splice(2, 0); // -> []
>
>     Am I reading it wrong or is this a bug in most engines?
>
What about we say it's a spec bug and say IE8- is wrong while the rest 
of the planet is right?

@mathias has a suggested fix: 
http://mathias.html5.org/specs/javascript/#array.prototype.splice%28start,-deletecount-,-item1-,-item2-,-%E2%80%A6-%29%29

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120703/6f077f63/attachment-0001.html>


More information about the es-discuss mailing list