rest parameters

Steve Fink sphink at gmail.com
Fri Oct 2 19:09:59 UTC 2015


On 10/02/2015 11:52 AM, Michaël Rouges wrote:
> Hi all,
>
> I'm coming to you for a tiny question... excuse me if already replied...
>
> Where the rest parameter are only declarable at the end of the 
> arguments list, like this, please?
>
> `
> void function (a, ...b, c) {
> // b = [2, 3]
> }(1, 2, 3, 4);
> `
>
> Any real reasons?

I don't know, but I can speculate. It's not at all obvious how ...args 
in the middle should behave: what if you have two rest arguments? Is 
that forbidden, or is one greedy? What if one of the trailing parameters 
has a default value? Also, iiuc the spec treats "undefined" the same as 
"nonexistent" in most places. So what should your function do when 
passed (1, 2, 3, undefined)?

In short, it seems like a hairball of complexity for no real gain.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151002/c5c07057/attachment.html>


More information about the es-discuss mailing list