rest参数:
eg:...args
看到这个名字就知道他是一个rest的东西,用于函数传参的时候,把参数规成一个数组.
rest参数和 arguments 功能类似都是获取实参列表
function foo(a,b,c,...args){
console.log(args);
}
foo(1,2,3,4,5,6,7);///
(4) [3, 4, 5, 6]
把参数放在一个数组里面
拓展运算符
const a = [1,2,3,5,6];
console.log(...a)
1 2 3 5 6
是rest的逆操作,把数组展开