[...[], 1]
替代ES5中函数的 apply 方法
ES6中有扩展运算符,我们不再需要apply方法将数组转换为函数参数了。...ES6的写法
function f(x, y, z) {
// ...
}
let args = [0, 1, 2];
f(...args);
下面是扩展运算符取代apply方法的一个实际的例子:...// ES5 的写法
Math.max.apply(null, [14, 3, 77])
// ES6 的写法
Math.max(...[14, 3, 77])
// 等同于
Math.max(14,...);
// [ 'a', 'b', 'c', 'd', 'e' ]
// ES6 的合并数组
[...arr1, ...arr2, ...arr3]
// [ 'a', 'b', 'c', 'd',...对于那些没有部署 Iterator 接口的类似数组的对象(如普通object),扩展运算符就无法将其转为真正的数组。