Skip to content

Instantly share code, notes, and snippets.

@pwlin
Created June 22, 2010 21:11
Show Gist options
  • Save pwlin/449092 to your computer and use it in GitHub Desktop.
Save pwlin/449092 to your computer and use it in GitHub Desktop.
for (i=0;i<11;i++){
setTimeout(function(x){return function(){alert(x)};}(i),1000);
}
function(x){return function(){alert(x)};}(i)
function func(x) {return function(){alert(x)};} // defines the function
func(i); // runs the function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment