📜  javascript代码示例中计时器的工作

📅  最后修改于: 2022-03-11 15:04:20.149000             🧑  作者: Mango

代码示例2
Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. 
This is done by using the functions 
1. setTimeout
2. setInterval
3. clearInterval

The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. 
The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. 
The clearInterval(id) function instructs the timer to stop.