From e7f4fd5e5fec90f2f2251ebe19e14f2e3ac8ce20 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Mon, 3 Aug 2020 09:15:19 +0530 Subject: [PATCH] update post: Closure and this - How are variables resolved within functions? --- ckddoqwv80154xvs198jkaa5m.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ckddoqwv80154xvs198jkaa5m.md b/ckddoqwv80154xvs198jkaa5m.md index 955ea3f..058d5e4 100644 --- a/ckddoqwv80154xvs198jkaa5m.md +++ b/ckddoqwv80154xvs198jkaa5m.md @@ -106,11 +106,11 @@ 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 -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), +For variable lookup, +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. This lookup will finally end when it reaches the global scope (doesn't have parent scope). If the variable is still not found, it will throw a `ReferenceError`.