You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/03-closure/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Let's consider two situations to begin with, and then study the internal mechani
63
63
64
64
To understand what's going on, let's first discuss what a "variable" actually is.
65
65
66
-
In JavaScript, every running function, code block `{...}`, and the script as a whole has an internal (hidden) associated object known as the *Lexical Environment*.
66
+
In JavaScript, every running function, code block `{...}`, and the script as a whole have an internal (hidden) associated object known as the *Lexical Environment*.
67
67
68
68
The Lexical Environment object consists of two parts:
69
69
@@ -117,7 +117,7 @@ The code below demonstrates that the Lexical Environment is non-empty from the b
117
117
118
118
Now let's go on and explore what happens when a function accesses an outer variable.
119
119
120
-
During the call, `say()` uses the outer variable `phrase`, let's look at the details of what's going on.
120
+
During the call, `say()` uses the outer variable `phrase`. Let's look at the details of what's going on.
121
121
122
122
When a function runs, a new Lexical Environment is created automatically to store local variables and parameters of the call.
123
123
@@ -149,7 +149,7 @@ The inner Lexical Environment has a reference to the `outer` one.
149
149
150
150
**When the code wants to access a variable -- the inner Lexical Environment is searched first, then the outer one, then the more outer one and so on until the global one.**
151
151
152
-
If a variable is not found anywhere, that's an error in strict mode (without`use strict`, an assignment to a non-existing variable, like `user ="John"` creates a new global variable `user`, that's for backwards compatibility).
152
+
If a variable is not found anywhere, that's an error in strict mode. Without`use strict`, an assignment to a non-existing variable like `user ="John"` creates a new global variable `user`. That's for backwards compatibility.
0 commit comments