First example (works as expected):
let timer = function (i) {
setTimeout(() => {
console.log(i);
}, i * 1000) // logging every second
};
for (let i = 0; i < 5000; ++i) {
timer(i)
}
Now let's change delay of timeout to 1 hour (1000 * 60 * 60)
let timer = function (i) {
setTimeout(() => {
console.log(i);
}, i * 1000 * 60 * 60) // logging every hour
};
for (let i = 0; i < 5000; ++i) {
timer(i)
}
This code doesn't work as i'm expect it. I expected logging for every hour. You can try to run it by yourself.