JAVASCRIPT CLIMBSChapter 5 · JS Functions and Classes
Scope and closures
A closure is created when an inner function remembers variables from its outer lexical environment, even after the outer function finishes executing.
Worked example
How it reads
- let count = 0 defines a private counter variable
- return () => { ... } maintains lookup access to the count variable

Cloud tip: Closures allow you to create private state variables in JavaScript.


