JavaScript timers are great tools for achieving recurrent behavior or even triggering delayed actions.
Whatever time-based logic you have, timers are the answer to your questions.
But if you don’t fully understand how they work, then you’ll be hitting your head against a JavaScript-made wall.
Let’s take a look at what timers we have available and how they work.
The main thing to remember about timers
Before we get into the nitty-gritty details of timers, there are a couple of very important things to remember about them.
They’re not exactly accurate
Timers either trigger an action after a certain number of seconds or repeat an action every time the specified timeout is over.
But while your expectation might be that they are accurate to the second, the reality is that they’re not.