JavaScript Currying

Beginner
6 min read
Updated: Nov 2026
3 examples

Definition and Usage

Currying turns a function of several arguments into a sequence of functions that each take one argument: f(a, b) becomes f(a)(b).

JavaScript Syntax

JavaScript
function curryAdd(a) {
  return function (b) {
    return a + b;
  };
}

const add10 = curryAdd(10);
console.log(add10(5));
console.log(curryAdd(2)(3));
Try it Editor

How It Works

  1. First call. curryAdd(10) returns a function that remembers a.
  2. Second call. Passing 5 computes 10 + 5.
  3. Chain style. You can also write curryAdd(2)(3) in one expression.

Examples

Example 1 — Reusable Mapper

Fix the multiplier, then map a list.

JavaScript
const multiply = (a) => (b) => a * b;
const triple = multiply(3);
console.log([1, 2, 3].map(triple).join(", "));
Try it Editor

How It Works

  1. Partial. multiply(3) returns a one-argument function.
  2. Map. Each list item is tripled.

Example 2 — Curried Predicate

Build a minimum-value filter.

JavaScript
const atLeast = (min) => (n) => n >= min;
console.log([1, 5, 9].filter(atLeast(5)).join(", "));
Try it Editor

How It Works

  1. Config first. Pass the threshold once.
  2. Reuse. The returned predicate works with filter.

Example 3 — Same Idea as Ramda

Ramda curries automatically so data can come last.

JavaScript
// Same shape Ramda encourages:
const prop = (key) => (obj) => obj[key];
const people = [{ name: "Ada" }, { name: "Grace" }];
console.log(people.map(prop("name")).join(", "));
Try it Editor

How It Works

  1. Key first. Fix the property name.
  2. Object later. Map supplies each object.

Frequently Asked Questions

Rewriting f(a, b, c) as f(a)(b)(c) so you can supply arguments one at a time.

Currying changes arity to one-at-a-time. Partial application fixes some arguments now and waits for the rest—related but not identical.

So you can build pipeline steps like R.map(fn) before the list arrives.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful