On Feb 2, 2012, at 11:49 AM, Herby Vojčík wrote:
>
>
> Allen Wirfs-Brock wrote:
>> That said, I'd hate to see things like:
>>
>> [,,,,,x] = someArray;
>>
>> and even
>> [a,,y] = someArray;
>>
>> can be easily missed.
>>
>> It isn't clear to me that we are doing ES programmers (especially those
>> with poor eyesight) a favor by allowing such expressions. What is the
>> evidence with JS1.7 up. How much usage do we see of such holes?
>
> If
>
> {"5":x} = someArray;
>
> and
>
> {"0":a, "2":y} = someArray;
>
> would be possible, there is probably little need for holes. In case of
+1
It isn't just possible, it is already specified as valid. and you don't need
the quotes around the array indices. But you need a set of params to deal with
the expression statement can't start with { problem. This wouldn't be the case
for binding position destructuring.
({5:x} = someArray);
({0:a, 2:y} = someArray);
>
> [a,b,c,d,,f] = someArray;
[a,b,c,d,...{1:f}] = someArray;
the above works for de-structuring asignments (where each destructuring element
including ... targets a LHS expression} but not for binding forms where ...
must be followed by an identifier. I suppose we could allow BindingPattern
instead of BindingIdentifier after the ... but maybe that is a step too far??
>
> one could always use (some conventional) anon-var, like _ (from Prolog):
>
> [a,b,c,d,_,f] = someArray;
>
> Herby
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss