Currying is simply a method that can use any function of the language (for example, closure) to achieve the desired result, but it is not determined which language function to use. Since shutters are not required for this currying (but in most cases shutters will be used)
Here is a small example of using currying, with and without using closure.
:
function addition(x,y) {
if (typeof y === "undefined" ) {
return function (y) {
return x + y;
}
}
return x + y;
}
var additionRemaining = addition(3);
additionRemaining(5);
new Function ( ):
function addition(x,y) {
if (typeof y === "undefined" ) {
return new Function('y','return '+x+' + y;');
}
return x + y;
}
var additionRemaining = addition(3);
additionRemaining(5);