JavaScript

this, call, apply, bind Interview Questions

How this is decided, and when to use call, apply, and bind.

  • 5Questions with answers
  • 3Difficulty levels

Questions (5)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Intermediate
Question

How does this work in JavaScript? What do call, apply, and bind do?

Answer:

this depends on how the function is called, not where it was written. A method call uses the object. A plain function is undefined in strict mode. new gives a new instance. Arrow functions take this from the outer scope. call and apply run the function now with a this I choose. apply takes arguments as an array. bind returns a new function with this fixed, which is why old React class handlers used bind. If they mix arrows and regular functions in a snippet, I walk through each call site. That is the whole question.

Question 2
Interview Intermediate
Question

this in an arrow inside a method?

Answer:

Lexical this from the enclosing method. That is why arrows keep the instance in callbacks. A regular function callback is undefined this in strict mode. I would not put an arrow on a prototype if I need dynamic this.

Question 3
Interview Beginner
Question

bind versus an arrow wrapper?

Answer:

bind fixes this and can prepend args. Passing obj.method as a callback loses this. I would not bind in a render loop. Arrows are often clearer in modern code.

Question 4
Interview Intermediate
Question

What does new do to this?

Answer:

Creates object, sets this, sets prototype, returns this unless the constructor returns an object. Arrows cannot be newed. class is still this-based sugar.

Question 5
Interview Beginner
Question

call versus apply today?

Answer:

apply takes an array. Spread is the modern version. I recognize apply in old code. Math.max.apply is now Math.max(...arr) with spread limits.

Practice with AI mock interviews

Run JavaScript mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required