Skip to content

Instantly share code, notes, and snippets.

@tonydub
Created May 20, 2013 20:49
Show Gist options
  • Save tonydub/13e0d5befa864a58bbb6 to your computer and use it in GitHub Desktop.
Save tonydub/13e0d5befa864a58bbb6 to your computer and use it in GitHub Desktop.
var myRevealingModule = function () {
var privateCounter = 0;
function privateFunction() {
privateCounter++;
}
function publicFunction() {
publicIncrement();
}
function publicIncrement() {
privateFunction();
}
function publicGetCount(){
return privateCounter;
}
// Reveal public pointers to
// private functions and properties
return {
start: publicFunction,
increment: publicIncrement,
count: publicGetCount
};
}();
myRevealingModule.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment