_.bind. Creates a new function; view.click is unchanged until you assign it.
Compare.view.click === withBind is false.
bindAll. Overwrites view.click in place.
Choose. One-off callback → _.bind; several object methods → _.bindAll.
Compatibility
Browser & Runtime Support
_.bindAll is a Lodash Util helper since 0.1.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 0.1.0+
_.bindAll()
Available in [email protected] full builds and the lodash/bindAll modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 0.1+
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
_.bindAllLodash 0.1.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import bindAll from "lodash/bindAll" for smaller bundles. Use it when several object methods are passed as callbacks and must keep this.
Frequently Asked Questions
_.bindAll(object, …methodNames) overwrites the named methods on object with versions bound to that object, then returns object. Official use: bind view.click so a detached handler still reads this.label.
Yes. It replaces the listed method properties in place. The same object reference is returned.
As an array (_.bindAll(obj, ['click'])) or as separate strings (_.bindAll(obj, 'click', 'render')). Both forms work in Lodash 4.
_.bind(fn, thisArg) returns one new function and does not assign it. _.bindAll binds many methods and writes them back onto the object.
In JavaScript, this depends on how a function is called. Passing obj.method as a callback calls it without obj as the receiver unless it was bound first.
Use import bindAll from "lodash/bindAll" or require("lodash/bindAll"). Full build: import _ from "lodash" then _.bindAll.