Skip to content

Commit dfc29d3

Browse files
Add question on scopes&closures
1 parent 0398f2f commit dfc29d3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

code-snippets/scopes&closures.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,42 @@ const func = foo(7);
3838
</details>
3939

4040
</li>
41+
42+
---
43+
44+
<li>
45+
46+
47+
**What will be the output ?**
48+
49+
```JS
50+
const fn = () => {
51+
a = 2;
52+
console.log(a);
53+
}
54+
55+
fn();
56+
57+
58+
```
59+
60+
- A: `undefined`
61+
- B: `2`
62+
- C: `Uncaught ReferenceError: a is not defined`
63+
64+
<br/>
65+
66+
<details>
67+
<summary><b>Answer</b></summary>
68+
<p>
69+
70+
#### Option: B
71+
72+
</p>
73+
</details>
74+
75+
76+
</li>
77+
4178
</ol>
4279

0 commit comments

Comments
 (0)