What is Module design pattern?
javascript
const Counter = (function() {
// Private
let count = 0;
// Public API
return {
increment() {
count++;
},
getCount() {
return count;
}
};
})();
Counter.increment();
console.log(Counter.getCount()); // 1
console.log(Counter.count); // undefined - private!Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.