Skip to content

Instantly share code, notes, and snippets.

@timhettler
Created July 6, 2012 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timhettler/3061173 to your computer and use it in GitHub Desktop.
Save timhettler/3061173 to your computer and use it in GitHub Desktop.
"Interview code" that demonstrates knowledge of closures.
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