Skip to content

Instantly share code, notes, and snippets.

@tiagopog
Created February 1, 2016 14:06
Show Gist options
  • Select an option

  • Save tiagopog/b6536e8b1002f99bdeb8 to your computer and use it in GitHub Desktop.

Select an option

Save tiagopog/b6536e8b1002f99bdeb8 to your computer and use it in GitHub Desktop.
function add(x) {
return function(y) { return x + y; };
}
var addTo10 = add(10);
console.log(addTo10(5)); // 15
console.log(addTo10(10)); // 20
@tiagopog

tiagopog commented Feb 1, 2016

Copy link
Copy Markdown
Author

Short closure example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment