JavaScript bind() vs call() vs apply(): What's the Difference?

Learn how JavaScript bind, call, and apply set this, how their arguments differ, and when to use each method with practical examples.

JavaScript bind() vs call() vs apply(): What's the Difference?

bind() vs. call() vs. apply() in JavaScript

These three methods let you control the this value for a regular function. The easiest way to tell them apart is to ask two questions: does the function run now, and how are extra arguments passed?

  • call() runs the function now and takes arguments one by one.
  • apply() runs the function now and takes arguments as an array or other array-like value.
  • bind() returns a new function with this set; you call that new function later.

Run the examples in a modern browser console or recent Node.js.

Start with a regular function

function introduce(city, greeting) {
  return `${greeting}, I'm ${this.name} from ${city}.`;
}

const person = { name: "Mina" };

The function reads this.name, but it doesn't specify what this should be. The three methods provide a receiver when we call or prepare the function.

call(): set this and run now

The first argument to call() becomes this. Any function arguments follow one by one:

const message = introduce.call(person, "Dhaka", "Hello");
console.log(message); // Hello, I'm Mina from Dhaka.

Use call() when you want to invoke the function immediately and pass a short, known list of arguments.

apply(): set this and pass an array-like list

apply() also invokes the function immediately, but its second argument is an array or array-like object containing the function arguments:

const message = introduce.apply(person, ["Dhaka", "Hello"]);
console.log(message); // Hello, I'm Mina from Dhaka.

The first argument still provides this. The second is the list of arguments to pass to introduce.

Borrow a method with apply()

You can borrow a method from one object and use it with another compatible value as this. For example, Array.prototype.join works with array-like objects that have numbered properties and a length:

const listLike = {
  0: "red",
  1: "blue",
  length: 2,
};

const colors = Array.prototype.join.apply(listLike, [" / "]);
console.log(colors); // red / blue

Here, listLike becomes this inside join, and the array contains the separator argument. call() could do the same with one argument: Array.prototype.join.call(listLike, " / ").

bind(): prepare a function to call later

bind() doesn't run the original function. It returns a new function with this set to the value you provide:

const introduceMina = introduce.bind(person);

console.log(introduceMina("Dhaka", "Hi"));
// Hi, I'm Mina from Dhaka.

You can also provide some arguments when binding. Those arguments are placed before the arguments supplied when the bound function is called. This is called partial application:

const greetMina = introduce.bind(person, "Dhaka");

console.log(greetMina("Welcome"));
// Welcome, I'm Mina from Dhaka.

This can be useful when passing a method as a callback and you need it to keep a particular this. In older React class components, developers often used .bind(this) for event handlers in a constructor. Modern React commonly uses function components, though you'll still encounter bound methods in older code.

At a glance

MethodRuns the function now?How function arguments are passed
call(thisArg, arg1, arg2)YesOne by one
apply(thisArg, [arg1, arg2])YesIn an array or array-like object
bind(thisArg, arg1, arg2)No; returns a new functionBound arguments are set one by one; remaining arguments arrive when called

When you already have an array of arguments, spread syntax often makes a direct call easier to read:

const values = [4, 9, 2];
console.log(Math.max(...values)); // 9

Spread can replace many uses of apply() for forwarding arguments, but it doesn't replace bind() when you need a reusable function with a chosen this.

Arrow functions are different

call(), apply(), and bind() do not change an arrow function's this. An arrow has no own this; it inherits this from its surrounding scope:

const arrow = () => this;

console.log(arrow.call({ name: "Mina" }));
// The arrow still uses its surrounding this, not the object passed to call().

Use these methods with regular functions when you need to control this.

Common beginner mistakes

Expecting bind() to invoke the function

bind() only creates a new function. Call the returned function to run the original:

const boundIntroduce = introduce.bind(person);
boundIntroduce("Dhaka", "Hello");

Mixing up the argument formats

call(person, "Dhaka", "Hello") passes separate arguments. apply(person, ["Dhaka", "Hello"]) passes them in a list. Both invoke immediately.

Expecting these methods to override an arrow's this

They can't. Arrow functions inherit this lexically, so use a regular function if a caller-provided this is required.

Practice

Create a regular function that uses this and takes two arguments. Call it once with call(), once with apply(), then use bind() to make a reusable function with one argument already filled in. Compare when each function call happens and how you provide the arguments.

What we learned

  • All three methods can provide this to a regular function.
  • call() invokes immediately and takes arguments separately.
  • apply() invokes immediately and takes arguments as an array or array-like value.
  • bind() returns a new function to invoke later, optionally with some arguments pre-filled.
  • These methods cannot change an arrow function's lexical this.

Conclusion

Remember the timing and argument format: call and apply run now; bind prepares a function for later. Choose call for separate arguments, apply for an argument list, and bind when you need a reusable function with a particular this. That distinction covers most everyday uses.

Written by

Dev Likhon

Dev Likhon

Full Stack Developer & Tech Educator

6+ years of professional development experience.

About Me
Share:

Comments

Share what you learned or ask a question.

Loading comments...