Curry photo by Andy Hey @eastcoastkitchen

What is Currying?

Currying is a coding technique of converting a function with a set number of parameters in to a chain-able function, allowing it to have its parameters provided in stages.

For example, currying would allow it to be called like or etc.

Heres an example of a currying function:

function curry(targetFn, …existingArgs) {
return function(…args) {
const totalArgs = […existingArgs, …args]
if(totalArgs.length >= targetFn.length) {
return targetFn(…totalArgs)
return curry(targetFn, …totalArgs)

Note the use of the length property of the target function. Because of this, currying can only work on functions with required parameters. …

Jamie Pennell

I'm a full-stack developer with a focus towards the front end and a keen interest in React and TypeScript.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store