Rest parameter syntax
Russell Leggett
russell.leggett at gmail.com
Tue Jun 12 08:40:23 PDT 2012
On Tue, Jun 12, 2012 at 11:26 AM, Rick Waldron <waldron.rick at gmail.com>wrote:
>
>
> On Tue, Jun 12, 2012 at 10:38 AM, Felix Böhm <esdiscuss at feedic.com> wrote:
>
>> Per definition, rest parameters always need to be at the end of a
>> FormalParameterList. I was wondering if this limitation could be liftet.
>>
>
> Consider:
>
>
> function foo( a, b, ...others, c ) {
> return [ a, b, others, c ];
> }
>
>
> foo( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
>
>
> a b others
> [ 1, 2, [ 3, 4, 5, 6, 7, 8, 9 ] ]
>
>
> How do you resolve where to stop claiming arguments as items in the rest
> param "others"?
>
Well, I mean, technically speaking its no different than a very simple
regex.
> /(.)(.)(.*)(.)/.exec("123456789");
["123456789", "1", "2", "345678", "9"]
> /(.)(.)(.*)(.)/.exec("123");
["123", "1", "2", "", "3"]
>From that perspective, it seems pretty deterministic and easy to explain.
There's probably a reason I'm not thinking of, though.
- Russ
Rick
>
>
>
>
>
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/aefff25e/attachment.html>
More information about the es-discuss
mailing list