js this 和箭头函数中的this指向有什么不同

2025-04-08 03:39:35
推荐回答(1个)
回答1:

this._seconds = seconds; } Countdown.prototype._step = function() { console.log(this._seconds); if (this._seconds > 0) { this._seconds -= 1; } else { clearInterval(this._timer); } }; Countdown.prototype.start = function() { this._step(); this._timer = setInterval(function() { this._step(); }, 1000); }; new Countdown(10).start();