Created
February 3, 2022 15:50
-
-
Save alexshelkov/1449943c65aea361a200a4a160ae8840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i1 = 0; | |
while (i1 < 3) { | |
let i = i1; // 'i' is a block scoped variable, | |
// each code block have unique copy of it | |
setTimeout(() => { // timeout callback | |
console.log(i, i1); | |
}, i * 1000); | |
i1++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment