Lambda saysA closure is a function that remembers variables from where it was created.
When a function is defined inside another, it keeps access to the outer function's variables even after the outer one returns. That captured state is a closure — the basis of private data, factory functions, and memoization. It's why a counter factory can keep its own private count.
Power-ups you unlock
Inner function remembers its birth scope
State persists after the outer function returns
Powers private data and factory functions
Each call creates a fresh closure
The Mutator attacks — common mistakes
var in loops sharing one binding across closures
Memory leaks from closures holding large objects
Assuming the closure copies values (it references them)
Boss battleWrite a makeCounter() factory whose returned function increments a private count.