Sitemap

🔥 TOP bind() INTERVIEW QUESTIONS (with answers) 2025

--

✅ 1. What does bind() do in JavaScript?

Answer (short & perfect):

bind() returns a new function with a permanently set this value and optional preset arguments. It does not execute the function immediately.

✅ 2. What is the difference between call, apply, and bind?

call()  → executes immediately, arguments individually
apply() → executes immediately, arguments as array
bind() → does NOT execute, returns new function

✅ 3. What will be the output?

const person = { name: "Mahua" };
function sayHi() {
console.log(this.name);
}
const hi = sayHi.bind(person);
hi();

Answer:
"Mahua"

Because bind() permanently binds this to person.

✅ 4. Why do we need bind() in event listeners?

class Button {
constructor() {
this.count = 0;
document.querySelector("#btn")
.addEventListener("click", this.increment);
}
increment() {
console.log(this.count);
}
}

❌ Output → undefined
Because this refers to the DOM element, not class instance.

✔ Fix:

.addEventListener("click", this.increment.bind(this));

✅ 5. What will be the output? (Very popular)

const obj = { a: 10 };
function f() {
return this.a;
}
const f2 = f.bind(obj);
console.log(f2());
console.log(f());

Answer:

10
undefined (or window.a)

bind only affects the returned function, not the original one.

✅ 6. Can bind() be chained?

function f() { return this.x; }
const a = f.bind({ x: 1 });
const b = a.bind({ x: 2 });
console.log(b());

Answer: 1

Once a function is bound, further binding has no effect.

✅ 7. What happens if you pass null or undefined to bind()?

function check() { console.log(this); }
check.bind(null)();

Answer:
If strict mode → this = null
If non-strict mode → this = global object

✅ 8. How does bind() support partial application?

function multiply(a, b) {
return a * b;
}
const double = multiply.bind(null, 2);
console.log(double(5));

Output:

10

✅ 9. Write the polyfill for bind() (100% asked in senior interviews)

Function.prototype.myBind = function(context, ...presetArgs) {
const fn = this;
return function(...laterArgs) {
return fn.call(context, ...presetArgs, ...laterArgs);
};
};

🔥 10. Why does bind return a function instead of calling the original function?

Answer:

Get Mahua Chanda’s stories in your inbox

Join Medium for free to get updates from this writer.

Because the purpose of bind() is to create a new function where:

  • this is locked
  • some arguments may be pre-filled
  • the function can be called later

This is essential for:

  • event handlers
  • callbacks
  • currying
  • functional programming

🧠 11. What is the output? (Trick question)

const module = {
x: 42,
getX: function() {
return this.x;
}
};
const unbound = module.getX;
const bound = unbound.bind(module);
console.log(unbound()); // ?
console.log(bound()); // ?

Answer:

undefined (or window.x)
42

🟦 12. Can bind() override arrow function this?

const obj = { value: 10 };
const f = () => this.value;
const f2 = f.bind(obj);
console.log(f2());

Answer:
undefined
Because arrow functions don’t have their own this, and bind() cannot override it.

🟪 13. Can bind() work with constructor functions?

Yes — but the new binding is ignored if function is called with new.

function Person(name) { this.name = name; }
const Bound = Person.bind({ name: "Wrong" });
console.log(new Bound("Right").name);

Answer:
"Right"
Because when using new, JavaScript ignores the this from bind.

--

--

Mahua Chanda
Mahua Chanda

Written by Mahua Chanda

I am Frontend focused Full Stack Developer - React, Javascript in frontend and JAVA for backend