Why this matters
Prevents memory leaks and background work after scope end.
Whenever you start an interval/timeout, also define a deterministic cleanup path that clears it.
Prevents memory leaks and background work after scope end.
Side-by-side examples engineers can pattern-match during review.
setInterval(tick,1000);const id=setInterval(tick,1000); /* on teardown */ clearInterval(id);setTimeout(t,500)const id=setTimeout(t,500); clearTimeout(id)From the same buckets as this rule.