Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created July 23, 2009 23:05
Show Gist options
  • Save infynyxx/153723 to your computer and use it in GitHub Desktop.
Save infynyxx/153723 to your computer and use it in GitHub Desktop.
JS closure
function addGenerator(num) {
return function(toAdd) {
return num + toAdd;
}
}
var addFive = addGenerator(5);
console.log(addFive(4) == 9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment