Lodash _.partialRight() method

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

What you’ll learn

  • How _.partialRight anchors arguments at the tail of the call.
  • How invocation arguments fill the leading slots before merged partials.
  • How partialRight pairs with partialRight.placeholder for mixed tails.
  • How this compares to _.partial, _.curryRight, and _.bind.

Prerequisites

Read _.partial(), _.curryRight(), and the Function hub first.

  • Partial application: building functions by fixing some parameters.
  • Argument order: knowing which parameter sits left versus right.

Overview

_.partialRight(func, ...partials) merges caller-supplied arguments with trailing literals—perfect when APIs reserve dynamic values on the left and constants or callbacks on the right.

Syntax

javascript
_.partialRight(func, ...partials)
  • func: target invoker.
  • partials: trailing partial arguments applied after runtime inputs.
  • returns: wrapped function performing the merged call.
1

Freeze the trailing name

Classic lodash pattern: supply greeting later while locking name.

javascript
import partialRight from "lodash/partialRight";

function greet(greeting, name) {
  return greeting + " " + name;
}

const greetAda = partialRight(greet, "Ada");

greetAda("Hello"); // "Hello Ada"
2

Fix the denominator

Pass the numerator at invoke time while keeping the divisor constant.

javascript
import partialRight from "lodash/partialRight";

function divide(a, b) {
  return a / b;
}

const overTen = partialRight(divide, 10);

overTen(55); // 5.5
3

Anchor two trailing segments

Useful when filenames share extensions or locales.

javascript
import partialRight from "lodash/partialRight";

function joinTriple(head, middle, tail) {
  return [head, middle, tail].join(".");
}

const localeBundle = partialRight(joinTriple, "en", "json");

localeBundle("messages"); // "messages.en.json"

📋 _.partialRight vs _.partial vs _.curryRight

HelperMerge directionPick when
_.partialRightCall-site args first, partials appendedYou freeze suffix parameters
_.partialPartials precede call-site argsYou freeze prefix parameters
_.curryRightAccept arguments right-to-left across callsYou want staged invocation until arity fills

Pitfalls to avoid

Placeholder

Mixing sentinel imports

Match partialRight.placeholder to the same module graph as partialRight; do not splice in partial.placeholder unless docs confirm equivalence.

this

Object methods

partialRight does not fix this; bind first when you wrap prototypes.

Arity

Variadic surprises

Extra trailing arguments from callers still flow through—document expectations when wrapping variadic APIs.

❓ FAQ

It returns a wrapper that invokes func after appending your preset partial arguments to the arguments supplied at call time—so trailing parameters are filled first.
partial prepends fixed values before caller arguments; partialRight appends them afterward. Pick whichever direction matches the parameter you want to freeze.
Yes—use partialRight.placeholder (or the matching sentinel from your import style) to leave gaps among the trailing partials.
No more than partial does; supply bind separately when methods rely on object context.
Use import partialRight from "lodash/partialRight"; combine with partialRight.placeholder when you need deferred trailing slots.

Summary

Did you know?

Because _.partialRight shares Lodash’s createWrap machinery with partial, placeholder tokens resolve through the same replaceHolders pass—only the merge direction flips so preset values anchor the tail of the argument list.

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