Example 1 — Reusable Mapper
Fix the multiplier, then map a list.
const multiply = (a) => (b) => a * b;
const triple = multiply(3);
console.log([1, 2, 3].map(triple).join(", ")); How It Works
- Partial.
multiply(3)returns a one-argument function. - Map. Each list item is tripled.
