92 Flashcards
(7 cards)
1
Q
Scoping
A
How our program’s variables are organized and accessed
2
Q
Lexical Scoping
A
the ability for a function to access variables from parent scope
3
Q
Scope
A
Space or environment in which a certain variable is declared
4
Q
Scope of a variable
A
region of our code where a certain variable can be accessed
5
Q
3 Types of Scope
A
- Global Scope: variables are accessible everywhere
- Function (local) Scope: variables are accessible only inside function, not outside
- Block Scope (ES6): variables are accessible only inside block (only applies to let and const variables); IN STRICT MODE: functions are also block scoped
6
Q
Scope Chain
A
every scope always has access to all the variables from all its outer scopes: THIS is the scope chain!
7
Q
Variable Lookup
A
when a variable is not in the current scope, the engine looks up in the scope chain until it finds the variable it’s looking for