Currying in javascript

Currying transforms a function that takes multiple arguments into a sequence of functions that each take a single argument. It is used to build reusable, partially applied helpers and to compose logic step by step.

Example

// Uncurried
function add(a, b) {
  return a + b;
}

// Curried version
function curriedAdd(a) {
  return function (b) {
    return a + b;
  };
}

const add10 = curriedAdd(10);
add10(5); // 15

The curried add function lets you pre‑fill the first argument (10) and reuse the resulting function (add10) wherever you need to add 10.