setTimeout and setInterval
Schedule one-shot and repeating work, then cancel it with clearTimeout / clearInterval.
Interval counter
setInterval runs a callback every delay milliseconds until you clear it.
0
One-shot reminder
setTimeout runs once after the delay. Clear it before it fires to cancel.
Important JavaScript
const id = setInterval(function () {
ticks = ticks + 1;
}, 1000);
clearInterval(id);
const later = setTimeout(function () {
status.textContent = "Done.";
}, 1500);
clearTimeout(later);