Created
December 20, 2011 10:47
-
-
Save jbgutierrez/1501179 to your computer and use it in GitHub Desktop.
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
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