An array destructing specification choice
Axel Rauschmayer
axel at rauschma.de
Sat Nov 12 02:07:29 PST 2011
> Embedded spreads is already in the ES6 draft for both array literals and argument lists. I'm not at all sure that embedded rests in destructurings are such a good idea.
I think it would be nice to express “last element(s)", e.g. in function parameters (where the callback is usually at the end):
foo(arg1, arg2, ..., argn, callback)
> Just to start with, what does this mean:
>
> [a,b,...r,c,d = [1,2,3]
That seems related to
[a, b, c, d] = [1,2,3]
and to
[a,b,...r,c,d = [1,2,3,4]
Hence, I would guess:
a === 1
b === 2
r === []
c === 3
d === undefined
I agree with Claus Reinke that naming is tricky: Is destructuring assignment the reverse of invoking a constructor? Is it a desctructor, then? But that clashes with C++ terminology.
--
Dr. Axel Rauschmayer
axel at rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111112/a64bc9ad/attachment.html>
More information about the es-discuss
mailing list