Currying and Partial Application
Transform multi-argument functions into curried forms.
What Is Currying?
Currying transforms a function of many arguments into a chain of single-argument functions. Instead of f(a, b) you call f(a)(b).
The Classic Example
Here add takes one number and returns a function waiting for the next. TypeScript infers the nested function types automatically.
const add = (a: number) => (b: number) => a + b;
console.log(add(2)(3)); // 5All lessons in this course
- Pure Functions and Immutability
- Currying and Partial Application
- Function Composition with Types
- Typed pipe and flow Utilities