Created
August 22, 2012 16:34
-
-
Save viebel/3427266 to your computer and use it in GitHub Desktop.
javascript: function defined inside a loop
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 numbers = [1,2,3]; | |
for (var i = 0, n = numbers.length; i<n; i++) { | |
var num = numbers[i]; | |
setTimeout(function() { | |
console.log(num); | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment