Lodash _.curryRight() method
What you’ll learn
- How
_.curryRight(func, arity)collects arguments from the right, analogous to_.partialRight. - Call shapes from the Lodash docs:
curried(3)(2)(1), grouped batches, and placeholders. - When explicit
aritymatters and howguardmirrors_.curry. - Try each example in the editor (
?tryit=1,2,3) with Lodash from a CDN.
Prerequisites
Read _.curry() first for shared arity, placeholder, and guard ideas; optional Function hub.
- Partial application: fixing trailing parameters before leading ones.
_.partialRightmindset: arguments bind from the end of the parameter list.
Overview
_.curryRight(func, arity) is the sibling of _.curry: arguments apply from the right toward the left until func receives its full parameter list, then it executes. Official docs describe it as currying “in the manner of _.partialRight.”
Trailing-first calls
Natural fit when later parameters stabilize early.
Placeholder parity
curryRight.placeholder keeps skipped slots flexible mid-chain.
Tree-shakeable
Import lodash/curryRight for focused bundles.
Syntax
_.curryRight(func, [arity = func.length], [guard]) - func: function to curry from the right.
- arity: optional explicit slot count when
func.lengthmisreports. - guard: iteratee hook shared with
_.curry—truthy values drop the arity hint (arity = guard ? undefined : arity). - Returns: curried wrapper without restored
lengthmetadata (Lodash note).
Right-heavy chained calls
Supply c, then b, then a—or pass all three at once—the tuple matches [a, b, c].
import curryRight from "lodash/curryRight";
const abc = function (a, b, c) {
return [a, b, c];
};
const curried = curryRight(abc);
curried(3)(2)(1);
// => [1, 2, 3]
curried(1, 2, 3);
// => [1, 2, 3] Grouped calls from the right
Two trailing arguments arrive together; the final call supplies the leading parameter.
import curryRight from "lodash/curryRight";
const abc = function (a, b, c) {
return [a, b, c];
};
const curried = curryRight(abc);
curried(2, 3)(1);
// => [1, 2, 3] curryRight placeholders
Lodash doc pattern: after fixing c, skip one slot then finish with the middle and leading arguments.
import curryRight from "lodash/curryRight";
const abc = function (a, b, c) {
return [a, b, c];
};
const curried = curryRight(abc);
curried(3)(1, curryRight.placeholder)(2);
// => [1, 2, 3] 📋 _.curryRight vs _.curry
| Topic | _.curryRight | _.curry |
|---|---|---|
| Analogy | _.partialRight sequencing | _.partial sequencing |
| Typical call vibe | Later params first (curried(3)(2)(1)) | Earlier params first (curried(1)(2)(3)) |
| Placeholder | curryRight.placeholder | curry.placeholder |
Pair this page with _.curry() on this site; for rate-limited callbacks next in the Lodash docs, see _.debounce().
Pitfalls to avoid
Reversing call order
Muscle memory from _.curry can flip arguments—trace which parameter each segment binds.
func.lengthArity drift
Same guidance as _.curry: supply arity when metadata lies.
Guard flag
Collection helpers may invoke curryRight with guard semantics—ordinary usage ignores it.
❓ FAQ
Summary
- Purpose:
_.curryRight(func, arity)defers invocation until right-to-left argument slots fill. - Contrast:
_.currybinds left-first; both share placeholder and guard mechanics. - Next: Lodash _.debounce(), _.curry(), or official Lodash docs for _.curryRight.
curryRight is implemented with WRAP_CURRY_RIGHT_FLAG inside createWrap—the same guard trick as _.curry (arity = guard ? undefined : arity) so Lodash can reuse it safely as a collection iteratee.
6 people found this page helpful
