Skip to content

Instantly share code, notes, and snippets.

@iwek
Created January 20, 2013 05:33
Show Gist options
  • Save iwek/4576822 to your computer and use it in GitHub Desktop.
Save iwek/4576822 to your computer and use it in GitHub Desktop.
JavaScript Better Closure Example
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