Skip to content

Commit f4deba0

Browse files
authored
Merge pull request #604 from jsonkao/patch-1
Small changes in Advanced Functions -> Closures
2 parents 6dd1163 + 7b0be24 commit f4deba0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

1-js/06-advanced-functions/03-closure/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Here's what's going on in the `makeCounter` example step-by-step, follow it to m
339339

340340
![](lexenv-nested-makecounter-3.png)
341341

342-
Please note that on this step the inner function was created, but not yet called. The code inside `function() { return count++; }` is not running, we're going to return it.
342+
Please note that on this step the inner function was created, but not yet called. The code inside `function() { return count++; }` is not running; we're going to return it soon.
343343

344344
4. As the execution goes on, the call to `makeCounter()` finishes, and the result (the tiny nested function) is assigned to the global variable `counter`:
345345

@@ -380,7 +380,7 @@ But if there were no `let name` in `makeWorker()`, then the search would go outs
380380
```smart header="Closures"
381381
There is a general programming term "closure", that developers generally should know.
382382
383-
A [closure](https://en.wikipedia.org/wiki/Closure_(computer_programming)) is a function that remembers its outer variables and can access them. In some languages, that's not possible, or a function should be written in a special way to make it happen. But as explained above, in JavaScript all functions are naturally closures (there is only one exclusion, to be covered in <info:new-function>).
383+
A [closure](https://en.wikipedia.org/wiki/Closure_(computer_programming)) is a function that remembers its outer variables and can access them. In some languages, that's not possible, or a function should be written in a special way to make it happen. But as explained above, in JavaScript, all functions are naturally closures (there is only one exclusion, to be covered in <info:new-function>).
384384
385385
That is: they automatically remember where they were created using a hidden `[[Environment]]` property, and all of them can access outer variables.
386386

0 commit comments

Comments
 (0)