Bind a function to an object, meaning that whenever the function is called, the value of this will be the object. Optionally, pass arguments to pre-fill them (partial application) (official Underscore docs). Stable Function helper — not deprecated.
Pass the required arguments shown below. Underscore function helpers usually return a new function — check timing and call-count behavior carefully.
Syntax
Call _.bind. Start with this line.
Underscore
_.bind(function, object, *arguments)
Call
What it does
_.bind(function, object, *arguments)
Primary signature.
_.bind(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
var person = {
name: "Ada",
greet: function () {
return "hi " + this.name;
}
};
var unbound = person.greet;
// unbound() → this is not person (often broken)
var bound = _.bind(person.greet, person);
bound();
// → 'hi Ada'
Docs tip: use _.partial for partials without binding this.
Compatibility
Browser & Runtime Support
_.bind ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. Native Function.prototype.bind is also available in modern engines.
✓ Stable · Underscore 1.x
_.bind()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.bindUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Prefer a pinned CDN version (e.g. [email protected]). Native fn.bind is fine in modern apps.
Frequently Asked Questions
_.bind(function, object, *arguments) returns a new function that always runs with this set to object. Extra arguments are pre-filled (partial application). Official: _.bind(func, {name: 'moe'}, 'hi')() → 'hi: moe'.
Passing a method as a callback often loses its object, so this becomes undefined or the global object. _.bind locks this to the object you choose.
_.bind sets this (and can pre-fill args). _.partial only pre-fills arguments and leaves this alone.
_.bind returns one new bound function. _.bindAll binds named methods in place on an object for use as event handlers.
No. It returns a new function; the original is unchanged.
Modern engines have fn.bind(thisArg, ...args) with similar behavior. _.bind is consistent inside Underscore codebases and older environments.