function sum(){
let arr = [].slice.call(arguments);
let fn = function(){
let arr2 = [].slice.call(arguments);
return sum.apply(null,arr.concat(arr2));
}
fn.toString = function(){
return arr.reduce((v,n) = > v+n);
}
return fn;
}
Copy the code
sum(1) (2.3) (4.5.6) // f 21
Copy the code