Can someone please explain the below 'Currying' function. When I set a break point, I can see values 'b' and 'c' are undefined and returned. But how does the system get the value 7 for 'b' and 9 for 'c' in this case. Its printing the correct result for 5*7*9, ie 315 in console.
function multiply(a){
return function (b){
return function (c) {
return a*b*c ;
}
}
}
var answer = multiply(5)(7)(9);
console.log(answer);
a*b*cis run, the parametersa,bandcwill all have numeric values in this case. And I don't understand what you mean by the "how system understand and need to grab..." part.bis just a parameter of the function. The fact that the functions are nested doesn't change that.console.log(a, b, c)before the multiplication line.const multiply = (a) => (b) => (c) => a*b*c;) made it a lot clearer to me what I was doing.