function sum(a) {
let currentSum = a;
function f(b) {
currentSum += b;
return f;
}
f.toString = function() {
return currentSum;
};
console.log(f);
return f;
}
alert( sum(1)(2) ); // 3
alert( sum(5)(-1)(2) ); // 6
please help me to understand the difference between - return f and f(). what happen with function code when activate return f? how it work? why console.log(f) return a number? i know f() return result, but return f? i dont understand.