Dev Helpers

JavaScript / Functions

Curry a binary function

Dev Helpers · January 29, 2026

A curried function lets one call establish a policy and later calls supply the values. The returned function retains its first argument.

Worked example

const add = (a) => (b) => a + b;
console.log(add(5)(3));

Result

8

Implementation notes

Partial application is useful when several callbacks share the same configuration. A fresh closure for each render or map step is only worthwhile when that captured value actually differs.

Try it yourself

Create two functions with different first arguments and call them in alternating order.

Open the JavaScript example →

Editorial date January 29, 2026 · Published December 6, 2026

Related articles

Sum distances with a Euclidean norm

A diagonal is longer than either of its components. Math.hypot combines perpendicular distances without making the caller square each input.

Build an OS-independent path

Path conventions belong to the destination. Use an explicit path flavour when generating portable asset names.

Resolve ranked ties

A leaderboard needs an explicit tie policy. Ranking tied scores and sorting their display order are separate decisions.