bind() does not run a function. It gives you back a new function whose this value is locked. You can also fill in the first arguments ahead of time, and the new function receives the rest when you call it.
It solves a very common problem: a method loses its this when you pass it around as a callback, for example to setTimeout() or an event listener. bind() keeps the right object attached.
Remember
const bound = func.bind(thisArg, arg1, arg2);
thisArg → "this" is locked to this value
arg1... → optional; filled in first, always
returns → a NEW function (func is unchanged)
bind() does not run func.
Call bound() when you are ready.
Syntax
Call bind() on any function and keep the new function it returns.
A new function. Calling hello() runs greet with this set to user.
const double = multiply.bind(null, 2)
Also fixes the first argument. double(5) calls multiply(2, 5) and returns 10.
setTimeout(counter.increase.bind(counter), 100)
Pass a method as a callback without losing its this.
Built into JavaScript (ES5). Every function has it; no import required. Siblings: apply(), call() and toString().
Library declarations
JavaScript
// Function.prototype.bind (ES5)
func.bind(thisArg)
func.bind(thisArg, arg1, arg2, /* ..., */ argN)
// returns a new (bound) function
Parameters
Parameter
Description
thisArg
The value that this will have inside the new function, every time it is called. Pass null when the function does not use this. An arrow function ignores it.
arg1, arg2, ..., argN
Optional. Arguments that are filled in first, every time the new function is called. Arguments you give later are added after them.
Return Value
Return Value
Description
A new function
The bound function. Its name starts with "bound ", and its length is the original number of parameters minus the arguments you already filled in.
The original function
It is not changed. func still works exactly as before.
JavaScript Examples
Example 1 — Fix a Method That Lost Its this
A method that is copied into a variable no longer knows its object. bind() fixes that.
Later attempts fail. Binding again to b, or using call(b) on the bound function, does not change anything. All three lines print "A".
The original is untouched.whoAmI.call(b) still prints "B", and boundToA === whoAmI is false because bind() made a different function.
Compatibility
Browser & Runtime Support
bind() was added in ES5. Every modern browser and every Node.js version has it.
✓ ES5 · Widely supported
func.bind()
Supported in all current browsers and in Node.js, Deno and Bun. Internet Explorer 8 and older do not have it.
ES5Standard since
Google ChromeAll current versions · Desktop & Mobile
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Mozilla FirefoxAll current versions · Desktop & Mobile
Full support
Apple SafariAll current versions · macOS & iOS
Full support
OperaAll current versions
Full support
Samsung InternetAll versions · Android
Full support
Android WebViewAll current versions
Full support
Node.jsAll versions · Server runtime
Supported
DenoAll versions · JavaScript runtime
Supported
BunAll versions · JavaScript runtime
Supported
Internet Explorer9+ only · IE 8 and older: no
Partial support
func.bind()Excellent
Bottom line: Safe to use everywhere today. Only Internet Explorer 8 and older lack it, and they have not been supported for years.
Frequently Asked Questions
It creates a new function that is a copy of the original, with this locked to the value you pass and, optionally, the first arguments filled in. It does not run the function; you call the new function later.
call() and apply() run the function right away, with this set for that one run. bind() does not run anything; it returns a new function with this fixed permanently. call() takes arguments one by one, apply() takes them in an array.
When you pass obj.method as a callback, the function is called without obj, so this is lost. Writing obj.method.bind(obj) keeps the object attached. An arrow function, such as () => obj.method(), is another way to do the same.
No. The this of a bound function is permanent. Using bind(), call() or apply() on it again does not change this. To get a different this, call bind() on the original function again.
You can call it, and the preset arguments still work, but the this value is ignored, because an arrow function always uses the this of the place where it was written.