Lodash _.partial() method

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

What you’ll learn

  • How _.partial freezes leading arguments ahead of time.
  • How partial.placeholder reserves gaps for later callers.
  • How partial differs from bind, curry, and manual wrappers.
  • Pitfalls mixing modular placeholders with the monolithic _ export.

Prerequisites

Helpful reads: _.bind(), _.overArgs(), and the Function hub.

  • Functions as values: returning callables from helpers.
  • Arity: knowing which parameter each positional partial fills.

Overview

_.partial(func, ...partials) creates a function that calls func with your preset arguments merged ahead of runtime inputs—without forcing a this binding like bind.

Syntax

javascript
_.partial(func, ...partials)
  • func: original function to invoke.
  • partials: values (or placeholders) applied before caller-supplied arguments.
  • returns: wrapped function with merged arguments.
1

Freeze a leading operand

Build a unary helper from a binary without rewriting the core logic.

javascript
import partial from "lodash/partial";

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

const addTen = partial(add, 10);

addTen(5); // 15
2

Reserve a slot with partial.placeholder

Fix the right operand while letting the left arrive later.

javascript
import partial from "lodash/partial";

function multiply(a, b) {
  return a * b;
}

const timesFive = partial(multiply, partial.placeholder, 5);

timesFive(8); // 40
3

Prefix several literals

Great for URL builders or template segments shared across routes.

javascript
import partial from "lodash/partial";

function joinSegments(a, b, c) {
  return [a, b, c].join("/");
}

const apiPath = partial(joinSegments, "api", "v2");

apiPath("users"); // "api/v2/users"

📋 _.partial vs _.bind vs _.curry

HelperPrimary focusPick when
_.partialLeading argument applicationYou only need frozen parameters, not this
_.bindthis plus partial argumentsMethods must keep owner context
_.curryProgressive arity fillingYou want multiple staged calls until arity completes

Pitfalls to avoid

Placeholder

Wrong sentinel reference

Modular partial.placeholder differs from the monolithic _ export—never mix placeholders from different entry points.

this

Methods needing context

Partial does not bind this; wrap with bind or arrow-bound methods when object state matters.

Arity

Surprising argument order

Sketch parameter indices before stacking partials so placeholders line up with how callers will invoke the wrapper.

❓ FAQ

A wrapper that prepends your partial values to whatever arguments the caller supplies when the wrapper runs.
A sentinel marking argument positions that stay open until invocation—later call arguments fill those gaps in order.
bind takes thisArg first for explicit this binding. partial only handles argument partial application; use bind when fixing this matters.
Not directly—you either reorder with _.rearg / _.flip or reserve earlier slots with placeholders so trailing literals bind correctly.
Use import partial from "lodash/partial"; access deferred slots via partial.placeholder in modular imports.

Summary

Did you know?

Lodash implements _.partial through the same createWrap pathway as bind, so placeholder substitution (replaceHolders) behaves consistently—you can mix fixed values and deferred slots before later arguments append.

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