Tab Atkins Jr. (2014-04-11T17:53:33.000Z)
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
domenic at domenicdenicola.com (2014-04-15T15:49:00.872Z)
You skipped the most interesting case - what to do when the list is
*almost* long enough to accommodate all of the non-rest params.

```js
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?