Skip to content

Instantly share code, notes, and snippets.

@rafaelcanovas
Created February 16, 2012 18:34
Show Gist options
  • Save rafaelcanovas/1846912 to your computer and use it in GitHub Desktop.
Save rafaelcanovas/1846912 to your computer and use it in GitHub Desktop.
Closure
function fooAdd(x) {
var y = 2;
return function() {
return x + y;
}
}
var fooClosure = fooAdd(5);
alert(fooClosure());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment