Sitemap
Bhairab Patra

Bhairab Patra

Member-only story

What are bind(), call(), and apply()?

3 min readJul 8, 2025

--

All three are methods available on JavaScript functions. They allow you to explicitly set the this context inside a function and optionally pass arguments to it.

Press enter or click to view image in full size

Analogy: Borrowing a Bike

Imagine you have a bike (function) that belongs to Person A (this). Sometimes Person B or C wants to use the same bike (reuse the function), but they want it to behave as if they own it (change the this context). So:

call() — Person B borrows the bike and rides it instantly, telling it where to go.

apply() — Same as call(), but gives directions as a list (array).

bind() — Person B borrows the bike, but saves it for later. They’ll ride it whenever they want.

✅ call() – Call the function with a given this and arguments

Concept

  • Calls the function immediately
  • First parameter is the this context
  • Rest are comma-separated arguments
function greet(language) {
console.log(`${this.name} says hello in ${language}`);
}

const person = { name: "Bhairab" };

greet.call(person, "JavaScript"); // Bhairab says hello in JavaScript

✅ apply() – Like call() but…

--

--