How do arrow functions treat `this` differently?
Quick answer
Arrow functions have no own `this` — they capture it lexically from the surrounding scope and can't be rebound.
In detail
An arrow function takes `this` from where it's defined, and call/apply/bind cannot change it. That makes arrows perfect for callbacks inside methods (they keep the outer `this`) but wrong as object methods that need their own `this`.
1const timer = {
2 secs: 0,
3 start() { setInterval(() => this.secs++, 1000); } // arrow keeps `this`=timer
4};
5const bad = { name: "x", get: () => this.name };
6bad.get(); // undefined — arrow's `this` is the outer scopeWhy interviewers ask this: A favourite follow-up to the `this` question.
This is 1 of 118+ questions in the JavaScript Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the JavaScript Interview Kit → ₹299