function add(...num) { const sum = num.reduce((acc, cur) => acc + cur, 0) console.log(sum) return add.bind(this, ...num) } function add2(...num) { let args = [...num] let next = function (...s) { args.push(...s); return next } next.toString = function () { return args.reduce((acc, cur) => acc + cur); } // next.valueOf = function () { // return args.reduce((acc, cur) => acc + cur); // } return next } // add(1)(2)(2,5) console.log(add2(2)(3)(4,5))