Hint
Each factory call creates a new lexical environment. This is the module pattern for private state.
function makeCounter() {
let count = 0;
return {
inc() { count++; },
get() { return count; },
};
}
const a = makeCounter();
const b = makeCounter();
a.inc(); a.inc();
b.inc();
console.log(a.get());
console.log(b.get());2 1
Explanation: Each makeCounter() call creates a fresh closure scope with its own count. a and b are completely independent.
Key Insight: Each factory call creates a new lexical environment. This is the module pattern for private state.