Open rogerxu opened 7 years ago
(function() {
let privateVar = 'secret';
function privateFunction() {
console.log(`Name: ${privateVar}`);
}
function publicSetName(name) {
privateVar = name;
}
function publicGetName() {
return privateFunction();
}
return {
setName: publicSetName,
getName: publicGetName,
};
}());
Revealing Module - Learning JavaScript Design Patterns