Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object JavaScript - Revealing Module Pattern
var Module = (function() {
// All functions now have direct access to each other
var privateFunc = function() {
publicFunc1();
};
var publicFunc1 = function() {
publicFunc2();
};
var publicFunc2 = function() {
privateFunc();
};
// Return the object that is assigned to Module
return {
publicFunc1: publicFunc1,
publicFunc2: publicFunc2
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment