This commit is contained in:
Ilya Kantor 2019-12-26 14:59:57 +03:00
parent 5b195795da
commit 964ed57c42
39 changed files with 365 additions and 461 deletions

View file

@ -0,0 +1,9 @@
The answer is: **Pete**.
The `work()` function in the code below gets `name` from the place of its origin through the outer lexical environment reference:
![](lexenv-nested-work.svg)
So, the result is `"Pete"` here.
But if there were no `let name` in `makeWorker()`, then the search would go outside and take the global variable as we can see from the chain above. In that case the result would be `"John"`.