Skip to content

Instantly share code, notes, and snippets.

@quipu
Last active October 13, 2015 13:17
Show Gist options
  • Save quipu/4201617 to your computer and use it in GitHub Desktop.
Save quipu/4201617 to your computer and use it in GitHub Desktop.
Javascript Revealing Module pattern
var myRevealingModule = function () {
var privateVar = "Ben Cherry",
publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}
function publicSetName( strName ) {
privateName = strName;
}
function publicGetName() {
privateFunction();
}
// Reveal public pointers to
// private functions and properties
return {
setName: publicSetName,
greeting: publicVar,
getName: publicGetName
};
}();
myRevealingModule.setName( "Paul Kinlan" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment