参数默认值,剩余参数,拓展参数(default spread rest parameter)
参数默认值,剩余参数,拓展参数(default spread rest parameter)
默认参数
let aa=(name='wwrs')=>{
console.log(`Hello ${name}`);
}
aa();//Hello wwrs
aa('sss');//Hello sss
扩展参数
let bb=(a,b,c)=>{
console.log(a+b+c);//9
}
let dd=[2,3,4];
bb(...dd);
剩余参数
let he=(a,b,c,d)=>{
console.log(a+b+c+d);//10
}
he(1,2,3,4)
let he1=(s,j,...shi)=>{
console.log(shi);//[3, 4]
}
he1(1,2,3,4)