-
-
Save skokasik/7055683 to your computer and use it in GitHub Desktop.
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
/* | |
A quick sample of the module pattern from JavaScript Patterns | |
*/ | |
var app = app || {}; | |
app.module = (function(){ | |
// private members | |
var prop = 0; | |
//private functions | |
function myPrivateFunction(){ | |
prop ++; | |
} | |
// public api | |
return { | |
myPublic : function() { | |
return prop; | |
}, | |
myRevealingMethod : myPrivateFunction | |
} | |
})(); | |
app.module.myPublic(); // 0 | |
app.module.myRevealingMethod(); | |
app.module.myPublic(); // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment