Explain how the value of this is determined in JavaScript. Cover plain calls, method calls, new, explicit binding, arrow functions and event handlers.
Show the explanation
Model answer. For regular functions, this is decided at call time by how the function is called, in this order of priority:
- `new Fn()`:
thisis the brand-new object. - Explicit binding with
call,applyorbind:thisis the object you passed. - Method call
obj.method():thisisobj(the thing before the dot). - Plain call
fn():undefinedin strict mode or modules; the global object in sloppy mode.
Arrow functions ignore all of these: they take this from the surrounding scope where they were written.
const timer = {
seconds: 0,
start() {
setInterval(() => { this.seconds++; }, 1000); // arrow: this = timer
},
};
const start = timer.start;
start(); // plain call: this is undefined inside start (in strict mode)In a DOM event listener written as a regular function, this is the element the listener is attached to (event.currentTarget); with an arrow function it is whatever this was outside.
The most common bug is losing this by passing a method as a callback (setTimeout(obj.method)); fix it with an arrow wrapper or bind.
Original UniCircle question. Last reviewed 22 Oct 2026.
