Created
July 6, 2012 16:27
-
-
Save timhettler/3061173 to your computer and use it in GitHub Desktop.
"Interview code" that demonstrates knowledge of closures.
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<10;i++){ | |
(function(i){ | |
setTimeout(function(){console.warn(i)},i*1000); | |
})(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment