ES6 扩展运算符... 与rest

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35746765/article/details/82628183

// ...
arr1 = [1,2,3]
arr2 = [4,5,6]
arr3 = [7,8,9]
 
arr4 = [...arr1, ...arr2, ...arr3] //[1,2,3,4,5,6,7,8,9]  用于数组合并
console.log(arr4);

// rest   (相当于...的逆运算)
let [a,...rest] = [1,2,3,4];
console.log(a);//1
console.log(rest);//[2,3,4]

猜你喜欢

转载自blog.csdn.net/qq_35746765/article/details/82628183