Skip to content

What is Currying?

Currying transforms a function that takes multiple arguments into a sequence of functions, each taking a single argument. This allows partial application and creates more reusable and composable functions.

// Normal function
function add(a, b, c) {
return a + b + c;
}
// Curried version
function curriedAdd(a) {
return function (b) {
return function (c) {
return a + b + c;
};
};
}
console.log(curriedAdd(1)(2)(3)); // 6