Object JavaScript - Revealing Module Pattern
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
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