Skip to content

Commit ad40e08

Browse files
authored
Merge pull request #18 from harshith-venkatesh/main
Add question on scopes&closures
2 parents ea5cca9 + 17e0f8f commit ad40e08

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
- [DOM Events](./code-snippets/dom-events.md)
2222
- [Hoisting](./code-snippets/hoisting.md)
23-
- Scopes & Closures
23+
- [Scopes & Closures](./code-snippets/scopes&closures.md)
2424
- Functions
2525
- Objects
2626
- Error handling

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)