Skip to content

Commit bd0870a

Browse files
authored
Merge pull request #8 from lakbychance/patch-2
Create scopes&closures.md
2 parents 55cbd50 + ffd8a23 commit bd0870a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

code-snippets/scopes&closures.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div align="center">
2+
<h1>Scopes & Closures</h1>
3+
</div>
4+
5+
<ol>
6+
<li>
7+
8+
**Which variables end up being part of `func's` closure ?**
9+
10+
```JS
11+
var c = 10;
12+
13+
function foo(a){
14+
let b = 8;
15+
const d = 10;
16+
return function bar(){
17+
return a + d + c;
18+
}
19+
}
20+
21+
const func = foo(7);
22+
```
23+
24+
- A: `a and d`
25+
- B: `a,b and d`
26+
- C: `a,b,c and d`
27+
- D: `a,d and c`
28+
29+
<br/>
30+
31+
<details>
32+
<summary><b>Answer</b></summary>
33+
<p>
34+
35+
#### Option: A
36+
37+
</p>
38+
</details>
39+
40+
</li>
41+
</ol>
42+

0 commit comments

Comments
 (0)