update post: Closure and this - How are variables resolved within functions?

This commit is contained in:
2020-08-03 09:15:19 +05:30
parent c9cd6e5f98
commit e7f4fd5e5f
+2 -2
View File
@@ -106,10 +106,10 @@ function outer() {
### Variable lookup
Now, when we use something like `console.log(myText)` in the function body - it needs to resolve the value of the variable `myText`.
Now, when we use something like `console.log(myText)` in the function body - it needs to resolve or lookup the variable `myText`.
For variable lookup,
a. it will check in the current LexicalEnvironment (i.e. the new local scope) first, and
a. it will check in the current LexicalEnvironment (i.e. the new local scope) first, and.
b. if it doesn't find the variable there, it will check in it's parent scope (parent of LE = F.[[Environment]] = lexical/closure scope),
c. and so on.