Hint
setTimeout callbacks lose their this. Fix with arrow function: setTimeout(() => { this.seconds++ })
const timer = {
seconds: 0,
start() {
setTimeout(function() {
this.seconds++;
console.log(this.seconds);
}, 100);
}
};
timer.start();NaN
Explanation: The regular function callback passed to setTimeout loses context. this becomes the global object (or undefined in strict). global.seconds is undefined, undefined++ is NaN.
Key Insight: setTimeout callbacks lose their this. Fix with arrow function: setTimeout(() => { this.seconds++ })