Skip to main content

Scope ↔ Placewhere Variable is declared

Variable declare inside function store in VE of function's EC

Global Scope

Outside any Block. Variableaccess everywhere

Block Scope

Variable Lookup restrict to inside of Block

Function Scope

Variable access restrict to only inside function body.

(For functions) VE is same as Scope

Scope of a variable

Region of code where Variable can be accessed

!recall since JS has First-Class Functions - functions are just values stored in variables

References

  1. TDZ ↔ Region of Code outside Scope of a variable, variable uninitialized from Scope start to Declaration

  2. Scope Chain ↔ Link to Variable from outer Scopes to current Scope

  3. Lexical Environment ↔ current Scope environ where JS Engine read Code

  4. Dependency ↔ any Variable local to FC Scope to control Hook Trigger

  5. [Variable](variable) inside [**_Scope_**](scope) of hook is not relevant [Dependency](dependency_deps-array) ↔ true