<!-- !
timing function -->
1. setTimeout
Definition:
- The setTimeout function is used to execute a function or a block of code
once after a specified delay (in milliseconds).
2. setInterval
Definition:
- The setInterval function is used to repeatedly execute a function or a block
of code at specified intervals (in milliseconds).
3. clearTimeout
Definition:
- The clearTimeout function is used to cancel a timeout that was previously
set with setTimeout. It prevents the function passed to setTimeout from
executing.
4. clearInterval
Definition:
- The clearInterval function is used to cancel a repeated action that was
previously set with setInterval. It stops the function passed to setInterval
from executing repeatedly.
// ! setTimeout()
[Link]('start')
[Link]('middle')
setTimeout(()=>{
[Link]('this is setTimeout')
},5000)
[Link]('end')
let hello = ()=>{
[Link]('this is hello function')
}
setTimeout(hello,3000)
// ! setInterval()
setInterval(()=>{
[Link]('i am setInterval')
},1000)
// ! clearInterval
let interval = setInterval(()=>{
[Link]('hello')
},1000)
clearInterval(interval)
// ! clearTimeout
let timeout = setTimeout(()=>{
[Link]('hello')
},1000)
clearTimeout(timeout)