Simple concept
- scope
Space for storing variables so that they do not leak out
- Lexical scope
Scope determined by source code
- Block scope
The space keyword within curly braces declares let,const
- The scope chain
You can find the parenthesis scope in the outer layer
- The call stack
Stack structure, the function call will record the function address on the stack back and pop up
- Variable ascension
Variable and function declaration will be promoted to the top, if you have learned C language in college, you will find that C language is required to call before declaration, JS has done special processing
- Execution context
An abstract concept of the environment in which JavaScript code is parsed and executed
- closure
A declared function call inside a function can remember the environment variables of the outer function
Variable lifting phenomenon
Js runs a piece of code that does two things
- The first step is to parse the declaration and then record the declaration, which is equivalent to storing the variable name and assigning it to undefined
- The second part of the execution code, this time first with the declaration call this value is undefined
Closure phenomenon
When the outer function is called, the inner function finds and records the parent scope according to the lexical scope, and then references the parent scope after the call.