Inner functions having access to outer function's variables is called a closure.
A Closure has three scope-chains, it has access to:
A Closure has three scope-chains, it has access to:
- Its own scope
- The outer function's variables
- Global variables
Basic Closure Example: