ES7 提案将 Rest/Spread 运算符引入对象:
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
// x: 1, y: 2, z: { a: 3, b: 4 }
在 Redux 中常见的用法:
let state = { a: 1, b: 1 };
console.log({ ...state, b: 2 }); // {a: 1, b: 2}
// 等价于
Object.assign({}, state, { b: 2 });
原理很简单:{ ...state, b: 2 } → { a: 1, b: 1, b: 2 } → { a: 1, b: 2 }