Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAbout "LexicalEnvironment" and "VariableEnvironment" #736
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Nov 19, 2016
Member
A LexicalEnvironment is a local lexical scope, e.g., for let-defined variables. If you define a variable with let in a catch block, it is only visible within the catch block, and to implement that in the spec, we use a LexicalEnvironment. VariableEnvironment is the scope for things like var-defined variables. vars can be thought of as "hoisting" to the top of the function. To implement this in the spec, we give functions a new VariableEnvironment, but say that blocks inherit the enclosing VariableEnvironment.
Hope this helps. (Could someone with the rights please close this bug?)
|
A LexicalEnvironment is a local lexical scope, e.g., for Hope this helps. (Could someone with the rights please close this bug?) |
NE-SmallTown commentedNov 19, 2016
•
edited
Sorry to bother you for my confusion. I post a question What's the difference between “LexicalEnvironment” and “VariableEnvironment” in spec on stackoverflow.
I find that there is some people have the same confusion, such as Clarity on the difference between “LexicalEnvironment” and “VariableEnvironment” in ECMAScript/JavaScript, Why do catch clauses have their own lexical environment?
I read some answers, some of them clarify me, but I still have some confusion.
So I hope that you can answer the question to help me to understand it.
@wycats @bterlson @rwaldron @caridy @allenwb Thanks.