Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
Created December 20, 2011 10:47
Show Gist options
  • Save jbgutierrez/1501179 to your computer and use it in GitHub Desktop.
Save jbgutierrez/1501179 to your computer and use it in GitHub Desktop.
closures
var tmp = 1;
function foo(x) {
var tmp = 2;
return function (y) {
alert(x + y + (++tmp));
}
}
var bar = foo(3);
bar(tmp);
bar(tmp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment