I was reading the book when I saw this
function multiplier(factor) {
return number => number * factor;
}
While it's true that this is an example of a closure , this is also an example of a curried function.
Yes, the function with its parameters and local variables are added to the call stack and that's true in (most?) programming languages. I don't know of any language where that isn't true, but one could be written otherwise so I'm sure someone's done it. I would say the major difference between parameters/arguments and local variables is that the function has control over the local variables whereas the parameters are controlled by whatever is calling it. You can see the difference here, but they are more or less the same.
// You'll need to actually look in your dev tools to see the result
const test = test => test2 => test2;
console.log("Test:");
console.dir(test);
console.dir(test());
const best = function(best) {
return function(best2) {
return best2;
}
}
console.log("Best:");
console.dir(best);
console.dir(best());
// You'll need to actually look in your dev tools to see the result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With