Lexical scopes define the rules for implementation:
1 function scope is defined at the time of definition, not at the time of execution
2 to implement this lexical scope, the function contains not only the function code logic but also the current scope chain.
3 function objects can be interconnected by a scope chain, and variables inside the function can be stored within the scope of the function.
Variable scope: The scope of a variable is the area in the program source code that defines the variable.
1 inside a function, local variables take precedence over global variables with the same name.
2 JS is a function scope
3 function Scope: A variable is defined within the body of the function in which it is declared and within a function nested inside the function.
The function scope of 4 JS refers to: All variables declared within a function are always visible inside the function body.
5 variables as attributes: Variables declared with VAR are not configurable
6 Local variables can be considered as properties of a local object
7 If you consider a local variable as a property of a local custom object, then each piece of JavaScript code has a scope chain associated with it. And the scope chain is made up of some columns of objects, and this scope chain defines the scope of the variable.
8 When a function is defined, it actually saves a scope connection, and when called, it creates a new object to store her local variables, and adds the object to the saved scope face, creating a new scope "chain" that represents the function call.
The 9 object does not have a closure feature.
The lexical scope of JS