setinterval javascript vs settimeout code example
Example 1: difference between setTimeout() and setInterval()
.setTimeout() //executes the code after x seconds.
.setInterval() //executes the code **every** x seconds.
Example 2: js setinterval vs settimeout
var intervalID = setInterval(alert, 1000); // Will alert every second.
// clearInterval(intervalID); // Will clear the timer.
setTimeout(alert, 1000); // Will alert once, after a second.