Created
January 20, 2013 05:33
-
-
Save iwek/4576822 to your computer and use it in GitHub Desktop.
JavaScript Better Closure Example
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
function one(y) { | |
var z = 1; | |
return function g(y) { | |
var all = y + z; | |
return all; | |
} | |
} | |
var z=10; | |
var b = one(); | |
function two(t){ | |
alert(b(2)+10); | |
} | |
two(); // alerts(13) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment