What are Curry functions in JavaScript
Currying is a technique of evaluating function with multiple arguments, into sequence of function with single argument. That is, when we turn a function call add(1,2,3) into curriedAdd(1)(2)(3) .
function curriedAdd(x) {
return function(y) {
return function(z) {
return x + y + z;
};
}
}
curriedAdd(1)(2)(3) // result would be 6
let curriedAdd_1_2 = curriedAdd(1)(2);
curriedAdd_1_2(3) // result would be 6
curriedAdd_1_2(10) // result would be 13
References
Categories :
JavaScript