Concepts
Closure
A callable with access to the lexical environment in which it was created. Reads observe the captured binding’s current value, rather than necessarily an initial snapshot.
Formal Syntax & Structure
javascript syntaxjavascript
function outer() { return function inner() { /* use outer bindings */ }; }Working Example
Example Snippetjavascript
function make(){let n=0;return ()=>++n;} const c=make();console.log(c(),c());