Skip to content

Instantly share code, notes, and snippets.

@deepaksisodiya
Created December 21, 2014 17:04
var add = (function() {
var count = 0; // private variable
return function() { // public anonymous function
count += 1;
console.log(count);
};
})();
add(); // 1
add(); // 2
add(); // 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment