Skip to content
JavaScript·Intermediate·Coding·1 min read

How does this behave in arrow functions?

Short interview answer

An arrow captures this from its lexical environment and ignores call, apply, and bind attempts to replace it. That makes arrows useful for callbacks needing the enclosing instance, but unsuitable as dynamically bound object methods or constructors.

Example

JavaScript
const timer = {  seconds: 0,  start() {    setInterval(() => { this.seconds++; }, 1000); // arrow: `this` is `timer`  },};// A regular function here would get its own `this` (undefined/global).

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to The this keyword

Related questions