Method
setInterval()
setInterval(func, delay, arg0, arg1, /* … ,*/ argN)
function - A function to be executed every delay milliseconds.
code - An optional syntax allows you to include a string instead of a function,
delay Optional - The time, in milliseconds (thousandths of a second), the timer should delay in between executions of the specified function or code.
arg0, …, argN Optional - Additional arguments which are passed through to the function specified by func once the timer expires.
Flashtext() - (link)
clearInterval()
clearInterval(intervalID)
intervalID - The identifier of the repeated action you want to cancel. This ID was returned by the corresponding call to setInterval().
setTimeout()
setTimeout(functionRef, delay, param1, param2, /* … ,*/ paramN)
setTimeout() is an asynchronous function, meaning that the timer function will not pause execution of other functions in the functions stack. In other words, you cannot use setTimeout() to create a "pause" before the next function in the function stack fires.
setTimeout(() => {console.log("this is the first message")}, 5000);
setTimeout(() => {console.log("this is the second message")}, 3000);
setTimeout(() => {console.log("this is the third message")}, 1000);