Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
Created July 5, 2023 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cferdinandi/36a95e8b799fd78e623427e0b47c08a0 to your computer and use it in GitHub Desktop.
Save cferdinandi/36a95e8b799fd78e623427e0b47c08a0 to your computer and use it in GitHub Desktop.
/**
* 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