const add = function add(...params) {
const value = params.length === 1 ? params.shift() : eval(params.join('+'));
const fn = (...params) => add(value, ...params);
fn.valueOf = Number.bind(null, value);
return fn;
}
console.log(+add(1,3));
console.log(+add(1)(3));
console.log(+add(4,5,1)(3,7)(1,1,1,1,1,1,1,1,1,1,1,1)(0,8,10));
console.log(+add(1)(2)(3)(-6));