for (var i = 0; i < 5; i++) {
setTimeout(() => {
console.log(i);
}, i * 1000);
}
5
5
5
5
5
"The setTimeout function callback isn’t triggered until the for loop execution has completed." I didn't get this, can anyone please tell me why ?
Thank you!