Rest parameter anywhere

Tab Atkins Jr. jackalmage at gmail.com
Fri Apr 11 10:53:33 PDT 2014

```On Fri, Apr 11, 2014 at 5:39 AM, Егор Николаев <termi1uc1 at gmail.com> wrote:
> Long story short:
> ```javascript
> function test( a = 1, b = 2, ...rest, c = 4, d = 5) { console.log(a, b,
> rest, c, d) }
>
> test();                // 1, 2, [], 4, 5
> test(9, 8);            // 9, 8, [], 4, 5
> test(9, 8, 7, 6);      // 9, 8, [], 7, 6
> test(9, 8, 7, 6, 5, 4);// 9, 8, [7, 6], 5, 4
>
> let [a = 1, b = 2, ...rest, c = 4, d = 5] = [];                // a == 1, b
> == 2, rest == [], c == 4, d == 5
> let [a = 1, b = 2, ...rest, c = 4, d = 5] = [9, 8];            // a == 9, b
> == 8, rest == [], c == 4, d == 5
> let [a = 1, b = 2, ...rest, c = 4, d = 5] = [9, 8, 7, 6];      // a == 9, b
> == 8, rest == [], c == 7, d == 6
> let [a = 1, b = 2, ...rest, c = 4, d = 5] = [9, 8, 7, 6, 5, 4];// a == 9, b
> == 8, rest == [7, 6], c == 5, d == 4
> ```

You skipped the most interesting case - what to do when the list is
*almost* long enough to accommodate all of the non-rest params.

`let [a = 1, b = 2, ...rest, c = 4, d = 5] = [9, 8, 7];`

It seems, from your second test case, that a=9 and b=8, but which
variables gets a value of 7 - c or d?

~TJ
```