Created
January 22, 2016 09:51
-
-
Save shuding/7f797947597c7f0aac83 to your computer and use it in GitHub Desktop.
setTimeout with scope
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
for (var i = 0; i < 3; ++i) { setTimeout(function () { console.log(i); }, 1000 * i); } | |
for (var i = 0; i < 3; ++i) { setTimeout(function (i) { console.log(i); }, 1000 * i, i); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment