Created
July 16, 2013 14:23
-
-
Save brschwar/6009194 to your computer and use it in GitHub Desktop.
Addy Osmani's Revealing Module Pattern Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Addy Osmani's Revealing Module Pattern Example | |
var myRevealingModule = function () { | |
var privateVar = "Ben Cherry", | |
publicVar = "Hey there!"; | |
function privateFunction() { | |
console.log( "Name:" + privateVar ); | |
} | |
function publicSetName( strName ) { | |
privateVar = 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