Back to results for “Functional Programming”
JavaScript › Functional Programming

What is currying and what problem does it solve?

Intermediate

Answer

Currying transforms a function taking multiple arguments into a sequence of functions each taking a single argument, allowing you to partially apply some arguments early and reuse the resulting specialized function later.
const curriedAdd = (a) => (b) => (c) => a + b + c;
const addFive = curriedAdd(5);
addFive(2)(3); // 10
Real-world example Creating a reusable, pre-configured validator like isLongerThan(8) from a generic two-argument comparison function.

Common follow-ups: How does currying relate to partial application, and are they the same thing?