Lodash _.bind() method

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

What you’ll learn

  • How _.bind(func, thisArg, ...partials) fixes this and prepends bound arguments.
  • Using _.bind.placeholder to leave holes filled on later calls.
  • Trade-offs versus native bind (especially function length).
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Optional reads Function hub, _.before(), and _.ary(); knowing how this behaves in plain functions helps.

  • this binding: methods expect a receiver object; detached references lose it unless wrapped.
  • Partial application: fixing the first arguments while leaving later ones open.

Overview

_.bind(func, thisArg, ...partials) returns a wrapper that calls func with this set to thisArg and any supplied partial arguments stitched before runtime parameters. Placeholders mark positions deferred until the wrapper runs—mirroring the official Lodash documentation greeting example.

Stable this

Extract methods as callbacks without losing the intended receiver.

Placeholders

Mix fixed and late-bound arguments in one wrapper.

Tree-shakeable

Import lodash/bind when the full bundle is unnecessary.

Syntax

javascript
_.bind(func, thisArg, ...partials)
  • func: the function to wrap; must be callable or Lodash throws.
  • thisArg: value passed as this when func runs.
  • partials: optional leading arguments; include _.bind.placeholder to skip slots filled by later calls.
  • Returns: a new bound function (Lodash does not adjust its length like native bind).
1

this plus a fixed greeting

Classic doc pattern: partially apply the greeting while this.user supplies the name fragment.

javascript
import bind from "lodash/bind";

function greet(greeting, punctuation) {
  return greeting + " " + this.user + punctuation;
}

const object = { user: "fred" };
const bound = bind(greet, object, "hi");

bound("!");
// => "hi fred!"
Try it Yourself
2

Bound with placeholders

Reserve the first argument for the eventual call while locking punctuation ahead of time.

javascript
import bind from "lodash/bind";

function greet(greeting, punctuation) {
  return greeting + " " + this.user + punctuation;
}

const object = { user: "fred" };
const bound = bind(greet, object, bind.placeholder, "!");

bound("hi");
// => "hi fred!"
Try it Yourself
3

Method as callback

Borrow an object method for Array.prototype.map while keeping the correct this for property reads.

javascript
import bind from "lodash/bind";

const counter = {
  prefix: "Item ",
  label(n) {
    return this.prefix + n;
  }
};

const labels = [1, 2].map(bind(counter.label, counter));
// => ["Item 1", "Item 2"]
Try it Yourself

📋 _.bind vs native bind

Topic_.bindFunction.prototype.bind
this argumentSecond parameter thisArgFirst parameter
Partial argumentsYes; supports placeholdersYes; fixed order only
Result lengthNot adjusted (Lodash note)Reduced toward arity

For methods whose identity lives on an object key, see _.bindKey.

Pitfalls to avoid

Arity hints

Libraries reading fn.length

Lodash bind does not mimic native length trimming—validators that depend on arity may disagree.

Placeholder

Wrong sentinel

Use the same placeholder object your build expects (bind.placeholder or the shared Lodash _ export)—random objects will not merge arguments.

Arrow functions

Lexical this

Arrow bodies ignore a bound thisArg; pass standard functions when binding matters.

❓ FAQ

Both fix this and can curry leading arguments. Lodash adds placeholder-aware partial application (defer specific argument slots until the wrapper is invoked). Native bind sets the bound function’s length metadata; Lodash bind does not.
A sentinel value (often the Lodash main export _ in monolithic builds) marking argument positions to fill when the returned function runs. Pass it among partials to skip early parameters.
partial applies arguments without supplying thisArg first—pick bind when you need both a fixed this and leading partials in one call.
No—it returns a new wrapper; the original function stays untouched.
Use import bind from "lodash/bind"; bind.placeholder is available on that function for modular builds.

Summary

Did you know?

Lodash’s bind builds on an internal createWrap pipeline with bind and partial bitmasks—placeholders are swapped at call time via replaceHolders, which is why skipping argument positions works the same across bind, partial, and friends.

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