Joined January 2018
·

technomen

Software Analyst at Houzlook
·
Bangalore
·
·

Posted to Be careful with setTimeout in loops over 1 year ago

for (let i = 1; i <= 5; ++i) {
setTimeout(function(){
console.log(i);
}, 1000);
}
let will create block level scope and it will work fine.

Achievements
1 Karma
0 Total ProTip Views
Interests & Skills