use timeout in for loop in js code example
Example 1: settimeout in a for loop javascript
// make sure to use "let" and not "var" if you want to capture
// the value of the external variable in a closure
for (let i = 0; i < 5; i++) {
setTimeout(() => console.log(i), 0);
}
Example 2: javascript settimeout loop
function timeout() {
setTimeout(function () {
// Do Something Here
// Then recall the parent function to
// create a recursive loop.
timeout();
}, 1000);
}