Course contentsShow
← JavaScript
Lesson 1768 of 2,72337. Functional Programming PatternsFree lesson

Currying vs Partial Application

Partial application fixes some arguments upfront; currying always returns single-argument functions.

Currying vs Partial Application

You'll learn how currying and partial application differ, even though they look similar and both help with function reusability.

The Core Difference

Both techniques let you "pre-fill" some arguments of a function, but they work differently:

Partial application fixes some arguments upfront and returns a function that takes the remaining arguments all at once:

function add(a, b, c) {
  return a + b + c;
}

// Partial application: fix 'a' and 'b', take 'c' later
function partial(fn, ...fixedArgs) {
  return (...remainingArgs) => fn(...fixedArgs, ...remainingArgs);
}

const add5and10 = partial(add, 5, 10);
console.log(add5and10(3)); // 18 — takes the last arg

Currying transforms a function into a chain where each step accepts exactly one argument:

// Curried version: always single-argument steps
const curriedAdd = a => b => c => a + b + c;

const step1 = curriedAdd(5);    // returns b => c => 5 + b + c
const step2 = step1(10);        // returns c => 5 + 10 + c
console.log(step2(3));          // 18

When to Use Each

  • Currying: Best for maximum composability and when you want uniform single-argument functions
  • Partial application: More flexible when you need to fix multiple arguments at once

Think of it this way: currying is like a vending machine that only accepts one coin at a time, while partial application is like pre-loading a coffee maker with water and beans — you just add the final ingredient when ready.

Key Takeaway:
Partial application fixes any number of arguments upfront and returns a function expecting the rest; currying transforms a function into a sequence of single-argument functions.