Currying

We already mentioned currying back in the Arrow functions section of Chapter 1, Becoming Functional – Several Questions, and in the One argument or many? section of Chapter 3, Starting Out with Functions – A Core Concept, but let's be more thorough here. Currying is a technique that enables you to only work with single-variable functions, even if you need a multiple-variable one.

The idea of converting a multi-variable function into a series of single-variable functions (or, more rigorously, reducing operators with several operands, to a sequence of applications of a single operand operator) was worked on by Moses Schönfinkel, and there have been some authors who suggest, not necessarily tongue-in-cheek, that currying would be more ...

Get Mastering JavaScript Functional Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.