Medium'this' Binding💻 Output Question

Arrow callback inside method preserves this

💡

Hint

Arrow callbacks inside methods inherit the method's this — solving the classic callback this-loss problem.

What does this output?

const timer = {
  seconds: 0,
  start() {
    const tick = () => ++this.seconds;
    tick(); tick(); tick();
    return this.seconds;
  }
};
console.log(timer.start());

Correct Output

3

Why this output?

Explanation: Arrow function tick inherits this from start's context (timer). Each tick() increments timer.seconds.

Key Insight: Arrow callbacks inside methods inherit the method's this — solving the classic callback this-loss problem.

More 'this' Binding Output Questions

EasyMethod call — this is the calling objectEasyArrow function has no own this — inherits lexicallyMediumbind permanently fixes this — call cannot override itMediumcall vs apply — same result, different syntax

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz