Skip to content

Instantly share code, notes, and snippets.

@xtbl
Last active December 17, 2015 18:09
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 xtbl/5651191 to your computer and use it in GitHub Desktop.
Save xtbl/5651191 to your computer and use it in GitHub Desktop.
JavaScript Module
var myModule = (function (){
var counter = 0;
function increment() {
counter += 1;
return counter;
}
function decrement() {
counter -= 1;
return counter;
}
function reset() {
counter = 0;
return counter;
}
return {
increment: increment,
decrement: decrement,
reset: reset
}
})()
myModule.increment();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment