How to Handle JavaScript this Questions in Interviews

JavaScript this keyword interview questions explained: the 5 binding rules, call vs apply vs bind, and predict-the-output traps that reject freshers.

PrepFox Team·
How to Handle JavaScript this Questions in Interviews

Why Indian Interviewers Keep Asking About this

Scroll through any frontend or full-stack JavaScript job posting on Naukri and you will see the same line: "strong JavaScript fundamentals." In technical rounds — from mass-recruiter campus placements to product startup interviews in Bengaluru and Hyderabad — one fundamental gets probed more than any other: the this keyword. It rarely comes as a theory question. You get five lines of code on a screen or a whiteboard and one instruction: what does this print? Most freshers freeze right there.

The good news: this follows a small set of rules. Learn the rules and the priority order, and almost every question becomes mechanical.

The 5 Binding Rules Interviewers Test

As MDN documents, this is decided at call time, not at definition time. There are five cases to know:

  • Default binding: a plain call like foo(). In non-strict mode this is the global object; in strict mode it is undefined.
  • Implicit binding: an object before the dot. In obj.greet(), this is obj.
  • Explicit binding: call, apply, or bind set this directly.
  • New binding: new Foo() creates a fresh object and points this at it.
  • Arrow functions: no this of their own — they inherit it from the surrounding scope, per MDN's arrow function guide.

When more than one rule could apply, the priority is: new > bind > call/apply > implicit > default. Arrow functions sit outside this list entirely.

call vs apply vs bind — The Follow-Up Behind Every Question

All three set this explicitly. The differences interviewers want:

  • call — invokes immediately, arguments passed one by one.
  • apply — invokes immediately, arguments passed as an array.
  • bind — does not invoke; returns a new function with this permanently fixed.

Then comes the classic follow-up: can you override a bound function's this with a second bind or a call? No. Only the first bind sticks, and new is the single exception that beats it.

4 Predict-the-Output Traps That Reject Freshers

1. The detached method

const obj = {
  x: 10,
  foo() { console.log(this.x); }
};
const fn = obj.foo;
fn(); // undefined — plain call, default binding

Assigning obj.foo to a variable strips the object context. Fix it with obj.foo.bind(obj) or call it as obj.foo().

2. setTimeout losing this

const user = {
  name: "Priya",
  show() {
    setTimeout(function () {
      console.log(this.name);
    }, 0);
  }
};
user.show(); // undefined

The callback is a plain call, so default binding applies. Swap the regular function for an arrow function and this is inherited from show — it prints "Priya".

3. Arrow functions ignore call, apply and bind

Passing a thisArg to .call() or .bind() on an arrow function is silently ignored. Arrow functions take their this from where they are written — nothing at the call site changes it.

4. new beats bind

function User(name) { this.name = name; }
const BoundUser = User.bind({ name: "ignored" });
const u = new BoundUser("Rahul");
console.log(u.name); // "Rahul"

new has the highest priority, so the hard-bound object is discarded.

How to Actually Prepare

Reading the rules is not the same as applying them under pressure. Three steps that work:

  1. Write each rule as a 3-line snippet and predict the output before running it.
  2. Work through 10-15 predict-the-output problems — freeCodeCamp's guide to the this keyword covers the same traps Indian interviewers ask.
  3. Say your reasoning out loud in a mock interview — the "why" matters as much as the answer.

For the broader question set, our JS interview questions for Indian freshers covers closures, hoisting and promises, which pair naturally with this. And since the resume is what gets you the technical round in the first place, build it with an ATS-friendly tool like the PrepFox resume builder.

A 30-Second Checklist for Any this Question

  • Arrow function? Lexical this — done.
  • Called with new? this is the new object.
  • call, apply or bind present? Explicit wins.
  • Object before the dot? Implicit binding.
  • None of the above? Default — global object, or undefined in strict mode.

Answer in that order and you will handle nearly every this question thrown at you — whether it arrives inside React class components, event handlers, or a bare five-line snippet.

Ready to put this into practice?

Practice mock interviews, build your resume, and get expert feedback — all on PrepFox.