Destructuring assignment
    解构赋值将属性和值从对象或数组中取出,赋值给其他变量

    1. var a, b, rest;
    2. var arr = [1, 2, 3, 4]
    3. [a, b, ...rest] = arr;
    4. console.log(a); // 1
    5. console.log(b); // 2
    6. console.log(rest); // [3, 4]
    7. ({a, b, ..rest}) = {a: 1, b: 2, c: 3, d:4});
    8. console.log(a); // 1
    9. console.log(b); // 2
    10. console.log(rest); // {c: 3, d: 4}
    11. var [x, y] = [1, 2];
    12. console.log(x); // 1
    13. console.log(y); // 2

    设置默认值

    1. var [a = 1, b = 2] = [3];
    2. a; // 3
    3. b; // 2
    4. var {c = 1, d = 2} = {c: 3}

    交换变量

    1. var a = 1;
    2. var b = 3;
    3. [a, b] = [b, a];
    4. console.log(a); // 3
    5. console.log(b); // 1

    解析从函数返回的数组

    1. fn = () => [1, 2];
    2. var [a, b] = fn();
    3. a; // 1
    4. b; // 2

    忽略函数的返回值

    1. fn = () => [1, 2, 3]
    2. var [a, , b] = fn();
    3. a // 1
    4. b // 3

    解构对象,改变变量名,设置默认值

    1. var {a:aa = 1, b:bb = 2} ={a: 3}
    2. aa // 3
    3. bb // 2