This commit is contained in:
Ilya Kantor 2017-07-01 10:29:07 +03:00
parent d391eb1f3c
commit db182040c8
2 changed files with 19 additions and 18 deletions

View file

@ -334,9 +334,9 @@ Here's what's going on in the `makeCounter` example step-by-step, follow it to m
3. During the execution of `makeCounter()`, a tiny nested function is created.
It doesn't matter whether the function is created using Function Declaration or Function Expression. All functions get the `[[Environment]]` property that references the Lexical Environment where they were made.
It doesn't matter whether the function is created using Function Declaration or Function Expression. All functions get the `[[Environment]]` property that references the Lexical Environment where they were made. So that new tiny nested function gets it as well.
For our new nested function that is the current Lexical Environment of `makeCounter()`:
For our new nested function the value of `[[Environment]]` is the current Lexical Environment of `makeCounter()` (where it was born):
![](lexenv-nested-makecounter-3.png)