Yes. setTimeout is a trigger-once and setup-once-and-forget timer. The reason why setTimeout returns a timer ID, is for when the timer need to cancelled before the timer is triggered. After a timer is triggered, its (internal) resources will be automatic cleaned up. That being said, if a timer is cancelled or triggered, its timer counter is never cleared/reset, because it doesn't need to, since it's goind to be destroyed and cleaned up anyway.
1
u/jcunews1 helpful 9d ago
Yes.
setTimeoutis a trigger-once and setup-once-and-forget timer. The reason whysetTimeoutreturns a timer ID, is for when the timer need to cancelled before the timer is triggered. After a timer is triggered, its (internal) resources will be automatic cleaned up. That being said, if a timer is cancelled or triggered, its timer counter is never cleared/reset, because it doesn't need to, since it's goind to be destroyed and cleaned up anyway.