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: questions/explain-the-concept-of-lexical-scoping/en-US.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Explain the concept of lexical scoping
6
6
7
7
Lexical scoping means that the scope of a variable is determined by its location within the source code, and nested functions have access to variables declared in their outer scope. For example:
8
8
9
-
```js
9
+
```js live
10
10
functionouterFunction() {
11
11
let outerVariable ='I am outside!';
12
12
@@ -36,7 +36,7 @@ When a function is defined, it captures the scope in which it was created. This
36
36
37
37
Consider the following example:
38
38
39
-
```js
39
+
```js live
40
40
functionouterFunction() {
41
41
let outerVariable ='I am outside!';
42
42
@@ -60,7 +60,7 @@ In this example:
60
60
61
61
Lexical scoping is closely related to closures. A closure is created when a function retains access to its lexical scope, even when the function is executed outside that scope.
0 commit comments