for(let i=0;i<5;i++) { timeoutID=setTimeout(function (){console.log(i);},i*1000); } code example
Example: for (var i = 0; i < 10; i++) { setTimeout(function () { console.log(i) }, 10) } What
for (var i = 0; i < 10; i++) {
setTimeout(
(function (i) {
console.log(i)
})(i),
10
)
}