holes in spread elements/arguments
Allen Wirfs-Brock
allen at wirfs-brock.com
Thu Sep 29 11:31:02 PDT 2011
On Sep 29, 2011, at 11:07 AM, Sean Eagan wrote:
> Sorry to drag on about array holes, but:
>
> Should holes in spread elements (e.g. [...holeyArray]) and arguments
> (e.g. f(...holeyArray)) reflect as holes in the array they are spliced
> into to avoid information loss ? The current proposal [1] reflects
> them as `undefined` values.
You need to read the draft ES6 spec. It specifies that spread used in array literals preserves holes. I haven't written the spec. for spread in argument lists but clearly interior holes need to be passed as undefined. Trailing holes in a spread in the final argument position could be trimmed but that would mean that:
foo.apply(undefined, new Array(5))
and
foo(...(new Array(5))
wouldn't pass the same thing which seems like it would be an issue.
Allen
More information about the es-discuss
mailing list