I generally understand currying and how it uses closures:
function foo(a) {
return function(b) {
return function(c) {
return a*b*c;
}
}
}
how would this be maximized though? Wouldn't this only save operational time if this were expecting to receive a lot of the same arguments?
For example, if you knew 5
would always be the first argument:
let first = foo(5);
then you can do:
first(8)(12);
or whatever else for the last 2 arguments.
However if you are not expecting the same arguments and you just use it as follows every time:
foo(3)(5)(9)
;
doesn't that defeat the purpose and is the same thing as making a normal function that just takes 3 arguments?
I am just trying to grasp the use case for this because in my head, it seems really limited.