传入不固定参数求和,使用rest参数 reduce函数 function x(...list){ return list.reduce((sum,n)=>sum+n,0); } x(1,2,3); // 6 x(); // 0