JS support timeout and timer. Here is their definition:
timeout - repeat execution of a code within specific time and it returns an integer that can be used to cancel pending timeout.
var timeout_id = setTimeout(f,500);
cleartTimeout(timeout_id);
timer - repeat exectuion of code at specific interval.
id = setInterval(F,5000);
clearInterval(id)
I am a little confused, what is their difference?
setTimeout executes the code only once.
setInterval executes the code at every xxx amount of time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With