JavaScript Function bind() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
Instance method

Definition

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.

JavaScript
const bound = func.bind(thisArg);
const bound = func.bind(thisArg, arg1, arg2, argN);
CallWhat it does
const hello = greet.bind(user)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

ParameterDescription
thisArgThe 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, ..., argNOptional. Arguments that are filled in first, every time the new function is called. Arguments you give later are added after them.

Return Value

Return ValueDescription
A new functionThe 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 functionIt 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.

JavaScript
class Counter {
  constructor() {
    this.count = 0;
  }

  increase() {
    this.count++;
    return this.count;
  }
}

const counter = new Counter();
const detached = counter.increase;

try {
  detached();
} catch (err) {
  console.log("Detached method: " + err.name);
}

const fixed = counter.increase.bind(counter);

console.log(fixed());
console.log(fixed());
console.log(counter.count);
Try It Yourself

How It Works

  1. The problem. detached is just the function, with no object around it. Inside a class, this is then undefined, so this.count++ throws a TypeError.
  2. The fix. counter.increase.bind(counter) returns a new function that always uses counter as this.
  3. It works anywhere. Each call to fixed() raises the count of the real counter object, so the last line also prints 2.

Example 2 — Preset the First Argument

Extra arguments given to bind() are filled in ahead of time. This is called partial application.

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

const double = multiply.bind(null, 2);
const triple = multiply.bind(null, 3);

console.log(double(5));
console.log(triple(5));

console.log(double.name);
console.log("Parameters: " + multiply.length + " -> " + double.length);
Try It Yourself

How It Works

  1. Fix the first number. multiply.bind(null, 2) makes a new function where a is always 2. null is the this value, which multiply does not use.
  2. Pass the rest later. double(5) becomes multiply(2, 5) and returns 10. triple(5) returns 15.
  3. Look at the new function. Its name is "bound multiply", and it now needs only 1 parameter instead of 2.

Example 3 — Check That the First bind() Wins

Try to change the this of a function that is already bound. The original function stays free to use.

JavaScript
function whoAmI() {
  return this.name;
}

const a = { name: "A" };
const b = { name: "B" };

const boundToA = whoAmI.bind(a);
const triedToChange = boundToA.bind(b);

console.log(boundToA());
console.log(triedToChange());
console.log(boundToA.call(b));
console.log(whoAmI.call(b));
console.log(boundToA === whoAmI);
Try It Yourself

How It Works

  1. Bind to A. boundToA always uses a as this.
  2. Later attempts fail. Binding again to b, or using call(b) on the bound function, does not change anything. All three lines print "A".
  3. The original is untouched. whoAmI.call(b) still prints "B", and boundToA === whoAmI is false because bind() made a different function.

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.

ES5 Standard since
Google Chrome All current versions · Desktop & Mobile
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Mozilla Firefox All current versions · Desktop & Mobile
Full support
Apple Safari All current versions · macOS & iOS
Full support
Opera All current versions
Full support
Samsung Internet All versions · Android
Full support
Android WebView All current versions
Full support
Node.js All versions · Server runtime
Supported
Deno All versions · JavaScript runtime
Supported
Bun All versions · JavaScript runtime
Supported
Internet Explorer 9+ 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.

Next: call()

Learn how to run a function right now with a chosen this value and arguments one by one.

call() tutorial →

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.

15 people found this page helpful