-
-
Save cferdinandi/36a95e8b799fd78e623427e0b47c08a0 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
/** | |
* Revealing Module Pattern Boilerplate | |
*/ | |
let MyLibrary = (function () { | |
// This variable is scoped internally | |
// It can't be accessed externally | |
let name = 'Wall-E'; | |
// This is returned at the end and can be run externally | |
function sayHi () { | |
console.log(`Hi ${name}`); | |
} | |
// This can also be run externally | |
function sayBye () { | |
console.log(`Bye ${name}`); | |
} | |
// Return and functions and variables that should be accessible externally | |
return {sayHi, sayBye}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment