Bind, Call, and Apply in JavaScript

Javascript 10 min min read Updated: Mar 09, 2026 Advanced
Bind, Call, and Apply in JavaScript
Advanced Topic 9 of 10

In JavaScript, functions are flexible and powerful. Sometimes developers need to control how a function is executed and what object it refers to. JavaScript provides three important methods for this purpose: call(), apply(), and bind().

These methods allow developers to explicitly set the value of this inside a function. They are commonly used when borrowing methods from other objects or when working with object-oriented programming patterns.

Understanding the this Keyword

Before learning about call, apply, and bind, it is important to understand the this keyword. In JavaScript, this refers to the object that is currently executing the function.

Sometimes developers need to change the value of this, and this is where call, apply, and bind become useful.

The call() Method

The call() method is used to invoke a function with a specified value of this. It allows arguments to be passed individually.

javascript let person = { name: "Rahul" }; function greet(city){ console.log("Hello " + this.name + " from " + city); } greet.call(person, "Delhi");
Output

Hello Rahul from Delhi

In this example, the function greet is executed with the object person as its context.

The apply() Method

The apply() method works similarly to call(). The main difference is that arguments are passed as an array instead of individual values.

javascript let person = { name: "Rahul" }; function greet(city, country){ console.log("Hello " + this.name + " from " + city + ", " + country); } greet.apply(person, ["Delhi", "India"]);
Output

Hello Rahul from Delhi, India

The bind() Method

The bind() method creates a new function with a specific value of this. Unlike call and apply, bind does not execute the function immediately. Instead, it returns a new function that can be called later.

javascript let person = { name: "Rahul" }; function greet(){ console.log("Hello " + this.name); } let newFunction = greet.bind(person); newFunction();
Output

Hello Rahul

Difference Between call, apply, and bind

  • call() executes the function immediately and accepts arguments individually.
  • apply() executes the function immediately but accepts arguments as an array.
  • bind() returns a new function with a fixed value of this.

Why These Methods are Important

The call, apply, and bind methods help developers control the execution context of functions. They are especially useful when working with objects, event handlers, and function borrowing.

These methods are widely used in modern JavaScript frameworks and libraries where managing the value of this is essential.

Conclusion

The call(), apply(), and bind() methods provide powerful ways to control how functions are executed in JavaScript. They allow developers to set the value of this and reuse functions across different objects.

Understanding these methods helps developers write more flexible and reusable JavaScript code.

In the next tutorial, you will learn about Promises in JavaScript, which provide a better approach for handling asynchronous operations.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators