Currying vs partial application
Partial application and currying are indeed similar - both techniques let you pass arguments to a function partially. But there is a clear difference in essence and purpose between them.
1. Definitions
Currying
Transforms a function with n arguments into a chain of functions, each of which takes exactly one argument.
// Original function
function add(a, b, c) {
return a + b + c;
}
// Curried version
const curriedAdd = a => b => c => a + b + c;
curriedAdd(1)(2)(3); // 6Each call returns a new function that expects the next argument. Currying is a pure functional transformation of the signature.
Partial Application
Creates a new function with pre-set (partially applied) arguments, but does not change the number of arguments the function takes.
function add(a, b, c) {
return a + b + c;
}
// Partially apply the first argument
const add1 = add.bind(null, 1);
add1(2, 3); // 6Partial application simply fixes some of the arguments, and the rest can be passed later together.
2. The main difference
| Criterion | Currying | Partial Application |
|---|---|---|
| What it does | Splits the function into a chain of one-argument functions | Fixes part of the original function's arguments |
| Arguments per step | 1 argument per call | Several arguments can be passed at once |
| Returns | A function expecting one next argument | A function expecting the remaining arguments |
| Call example | f(a)(b)(c) | f(a, b)(c) or f(a)(b, c) |
| Purpose | Unifying calls and composition | Reusing a function with pre-set arguments |
Example for clarity:
Currying:
const multiply = a => b => c => a * b * c;
multiply(2)(3)(4); // 24Partial application:
function multiply(a, b, c) {
return a * b * c;
}
const double = multiply.bind(null, 2); // fix a=2
double(3, 4); // 24Summary:
Currying is a formal transformation of a function into a sequence of one-argument calls. Partial Application is a practical technique for pre-filling part of the arguments and passing the rest later.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.