Skip to content

Instantly share code, notes, and snippets.

@NenadP
Created November 22, 2015 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NenadP/ff4bea6e21e6dec9fb91 to your computer and use it in GitHub Desktop.
Save NenadP/ff4bea6e21e6dec9fb91 to your computer and use it in GitHub Desktop.
Closure example
/*
* Closure example
*/
(function () {
function addOne() {
var num = 0;
return function () {
return num += 1;
};
}
var addMore = addOne();
console.log(addMore());
console.log(addMore());
console.log(addMore());
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment