What is currying and partial application?

JavaScript Functions & Scope Advanced 3–5 Yrs5+ Yrs Conceptual 1 min read

Quick Answer

Currying transforms a function of N arguments into N functions of one argument each: add(a)(b)(c). Partial application fixes some arguments now and returns a function expecting the rest: const add5 = add.bind(null, 5). Both build specialised functions from general ones and rely on closures.

Currying is turning a function that takes several arguments into a chain of functions that each take one — so add(1)(2)(3). Partial application is looser: you supply some of the arguments now and get back a function waiting for the rest, which is what bind does. Both are ways to make a specialised function out of a general one — like taking a generic log(level, message) and creating an error function with the level baked in. They both work because of closures.

  • Currying: const add = a => b => c => a + b + c;.
  • Partial: const log = (level, msg) => ...; const error = log.bind(null, 'ERROR');.
  • Useful for configuring a function once (a logger with a fixed prefix, a fetch with a fixed base URL) and for point-free composition in functional pipelines.
  • Don't over-curry ordinary code — it can hurt readability.