Rest parameter syntax
T.J. Crowder
tj at crowdersoftware.com
Tue Jun 12 08:51:59 PDT 2012
On 12 June 2012 16:42, Herby Vojčík <herby at mailbox.sk> wrote:
>
>> But I understand there are problems. First, what with optional params
> after ...rest. And the second, how to parse it when foo(1, 2) called?
>
>
I would think with
function foo(a, b, ...others, c) {
}
then given
foo(1, 2);
...within foo a is 1, b is 2, others is empty, and c is undefined. E.g.,
args prior to the restargs get priority over args after rest args. This is
consistent with
foo(1);
...where within foo a is 1, b is undefined, others is empty, and c is
undefined.
It does seem as though it can be deterministic, and pretty easy to explain.
Which isn't necessarily an endorsement, just identifying that this
particular issue doesn't immediately seem like a roadblock.
-- T.J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/cde4c977/attachment.html>
More information about the es-discuss
mailing list