The Revealing Module Pattern is a variation of the Module Pattern. It allows you to define all functions and variables in the private scope, and then selectively reveal those you want to be public.
const RevealingModule = (function() {
let privateVariable = 'I am private';
function privateFunction() {
console.log(privateVariable);
}
function publicFunction() {
privateFunction();
}
// Reveal public pointers to private functions and properties
return {
publicFunction: publicFunction
};
})();
RevealingModule.publicFunction(); // Output: I am private