.. 运算符, 是ES6里一个新引入的运算法, 也叫展开/收集运算符(也被叫做延展操作符 - spread operator),本篇文章讲解一下其具体的用法。
const a = [2, 3, 4]
const b = [1, ...a, 5]
console.log(b);// [1, 2, 3, 4, 5]
function foo(a, b, ...c) {
console.log(a, b, c)
}
foo(1, 2, 3, 4, 5); // 1, 2, [3, 4, 5]
const nodeList = document.getElementsByClassName("test");
const array = [...nodeList];
console.log(nodeList); // HTMLCollection [ div.test, div.test ]
console.log(array); // Array [ div.test, div.test ]
原文:https://www.cnblogs.com/jone-chen/p/12133441.html