Skip to content
UniCircle
MediumConceptualFunctions

Function currying

Question JS-FUN-005

What is currying? Write a curried version of a three-argument function and explain where currying is useful.

Show the explanation

Model answer. Currying turns a function of several arguments into a chain of functions that each take one argument: f(a, b, c) becomes f(a)(b)(c).

JavaScript
const volume = l => w => h => l * w * h;
volume(2)(3)(4);   // 24

// a general helper: curry any fixed-arity function
const curry = fn => function curried(...args) {
  return args.length >= fn.length ? fn(...args) : (...more) => curried(...args, ...more);
};
const price = curry((rate, qty, unit) => qty * unit * (1 + rate));
const withGst = price(0.18);    // fix the tax rate once
withGst(2)(500);                // 1180

Where it helps:

  • Partial application: fix some arguments early (a tax rate, a logger prefix, an API base URL) and reuse the specialised function.
  • Composition: single-argument functions plug neatly into pipelines and map.

Do not overuse it; for most application code, plain parameters are clearer.

Original UniCircle question. Last reviewed 22 Oct 2026.