Functions

Currying

Transforming a multi-arg function into a chain of single-arg functions.

advanced Experienced

Currying converts a function that takes many arguments into a sequence of functions that each take one, using closures to remember the earlier arguments.

Currying is ordering a coffee one choice at a time — size, then milk, then sugar — instead of shouting the whole order at once.

Key concepts

1
It enables partial application — fixing some arguments now and supplying the rest later — which is great for building specialised functions from general ones.
partial application
2
Currying is a favourite interview exercise because writing a generic curry helper tests your grasp of closures, recursion and fn.length.
curryfn.length