1 2 3 4 5 6 7 8 9 10 11 12 13
| function add(...args) { let parmas = args; function sum(){ parmas = [...parmas,...arguments]; return sum; } sum.sumOf = function(){ return parmas.reduce((p,c)=>p+c); } return sum; } console.log(add(1)(2)(3)(10)(10, 20).sumOf())
|