Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetTiemout in for loop not print consecutive values #36

Closed
SachAtTiwari opened this issue May 29, 2018 · 2 comments
Closed

SetTiemout in for loop not print consecutive values #36

SachAtTiwari opened this issue May 29, 2018 · 2 comments

Comments

@SachAtTiwari
Copy link

SachAtTiwari commented May 29, 2018

for (var i = 1; i <= 2; i++) {
setTimeout(function() { alert(i) }, 100);
}

The use case for IIFE
Add if found suitable

@ganqqwerty
Copy link
Owner

ganqqwerty commented Jun 13, 2018

Yeah, it’s a good one if you don’t have es6 block scoping with let/const. Thanks!

@ganqqwerty
Copy link
Owner

do you have some question in mind where I can add this example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants