Rest parameter syntax

T.J. Crowder tj at crowdersoftware.com
Tue Jun 12 09:10:14 PDT 2012


On 12 June 2012 17:03, Herby Vojčík <herby at mailbox.sk> wrote:

> function foo (a, b, ...rest, c, d) { ... }
> foo(1, 2, 3)
>
> What here?
>
> Yes, [1, 2, [], 3, undefined] is probably the most logical one. But then d
> is not the last one (yes, it is only last one when there is at least four
> of them).
>

Yeah, I was regretting not addressing that case. :-)

I'd say your interpretation (1, 2, [], 3, undefined) would be the best
answer, and easiest to explain. There's a temptation to suggest that you
could reverse c and d (1, 2, [], undefined, 3), but that way surely lies
madness...

-- T.J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/b2b7733e/attachment.html>


More information about the es-discuss mailing list