function add(a,b,...args){
console.log(a);
console.log(b);
console.log(args); //[a,b,...]
}
特性:
1 rest参数输出的是一个数组
2 arguments是一个对象
扩展运算符 ...
一般用来:
1 解析数组为参数序列...[a,b,c] ⇒ a,b,c 这里是本质
2 数组合并
3 数组克隆
4 维数组转换为真数组
function add(a,b,...args){
console.log(a);
console.log(b);
console.log(args); //[a,b,...]
}
特性:
1 rest参数输出的是一个数组
2 arguments是一个对象
扩展运算符 ...
一般用来:
1 解析数组为参数序列...[a,b,c] ⇒ a,b,c 这里是本质
2 数组合并
3 数组克隆
4 维数组转换为真数组