Lodash _.curry() method

Beginner
⏱️ 7 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.curry(func, arity) builds intermediate functions until enough arguments arrive.
  • Familiar call shapes from the Lodash docs: chained calls, grouped arguments, and placeholders.
  • When to supply explicit arity versus relying on func.length.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Helpful background: _.bind() / _.bindKey() for placeholders; Function hub for category context.

  • Arity: how many positional parameters a function expects before it can run meaningfully.
  • Higher-order functions: functions that return functions capturing pending arguments.

Overview

_.curry(func, arity) wraps func so arguments can be supplied one call at a time—or merged across calls—until the configured arity is satisfied, then func executes with the accumulated parameters. Placeholders mark “skip this slot for now,” matching the official Lodash examples.

Incremental args

Shape APIs that receive configuration in stages without rewriting func.

Placeholders

Reorder partial applications with curry.placeholder.

Tree-shakeable

Import lodash/curry when the rest of Lodash is unnecessary.

Syntax

javascript
_.curry(func, [arity = func.length], [guard])
  • func: the function to curry; must be callable.
  • arity: optional cap on required arguments when func.length is wrong or zero.
  • guard: internal iteratee hook—when truthy Lodash ignores the supplied arity (see source arity = guard ? undefined : arity).
  • Returns: a curried wrapper; official docs note length is not mirrored like native functions.
1

Classic chained calls

Each segment passes one more argument until all three slots fill—identical outcome to passing everything at once.

javascript
import curry from "lodash/curry";

const abc = function (a, b, c) {
  return [a, b, c];
};

const curried = curry(abc);

curried(1)(2)(3);
// => [1, 2, 3]

curried(1, 2, 3);
// => [1, 2, 3]
Try it Yourself
2

Grouped intermediate arguments

Lodash lets you batch arguments across calls—here two arguments arrive together before the final third.

javascript
import curry from "lodash/curry";

const abc = function (a, b, c) {
  return [a, b, c];
};

const curried = curry(abc);

curried(1, 2)(3);
// => [1, 2, 3]
Try it Yourself
3

Curried placeholders

Official pattern: pin a and c, circle back to supply b last.

javascript
import curry from "lodash/curry";

const abc = function (a, b, c) {
  return [a, b, c];
};

const curried = curry(abc);

curried(1)(curry.placeholder, 3)(2);
// => [1, 2, 3]
Try it Yourself

📋 _.curry vs _.partial

Topic_.curry_.partial
GoalSplit arity into sequential callsFix chosen arguments once
Order disciplineLeft-to-right slots until filledYou choose which positions are fixed
Placeholdercurry.placeholderpartial.placeholder

Right-to-left currying is _.curryRight.

Pitfalls to avoid

func.length

Arity surprises

Default parameters, rest params, or builds stripping metadata yield wrong counts—pass arity explicitly.

Variadic

arguments soup

Curry counts fixed slots; functions that ignore arity and read arguments need careful design.

Iteratees

Guard behavior

When Lodash invokes curry as an iteratee helper it enables guard semantics—normal application omits the guard.

❓ FAQ

A wrapper that accepts arguments from left to right until arity slots are filled; partial applications return further wrappers instead of calling func early.
When func.length is unreliable—variadic functions, defaulted parameters, or transpiled output—pass the exact parameter count as the second argument.
Lodash sets arity to undefined when guard is truthy so curry can behave as an iteratee (for example with _.map). Everyday callers omit it.
Curry splits multi-argument functions into successive calls in arity order. Partial fixes specific leading arguments once; combine styles depending on your API surface.
Lodash notes curried wrappers do not mirror native length trimming—tests or introspection relying on fn.length may differ from expectations.
Use import curry from "lodash/curry"; curry.placeholder matches other Lodash placeholder-aware helpers in modular builds.

Summary

Did you know?

Under the hood curry calls createWrap with WRAP_CURRY_FLAG; the optional guard argument exists so Lodash can treat _.map(collection, _.curry(fn)) correctly by dropping the iteratee’s arity hint.

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