Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5c64002

Browse files
Merge pull request #8 from HariAcidReign/restyled/pull-7
Restyle text updated
2 parents a6e17b7 + e0231f8 commit 5c64002

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎Notes/10-Closures.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Episode 10 : Closures in JS
2+
23
### Important Interview Question
34

4-
**Closure :** Function bundled together with its lexical environment/scope.
5+
**Closure :** Function bundled together with its lexical environment/scope.
56

67
```
78
JS is a weird language. You can pass functions as parameters to another function, assign a variable to an entire function, or even return a function.
@@ -19,9 +20,16 @@ console.log(z); // value of z is entire code of function y.
1920
2021
```
2122

22-
When functions are returned from another fun, they still maintain their lexical scope.
23-
- When y is returned, not only is the fun returned but the entire closure (fun y + its lexical scope) is returned and put inside z. So when z is used
24-
somewhere else in program, it still remembers var a inside x()
23+
When functions are returned from another fun, they still maintain their lexical
24+
scope.
25+
26+
- When y is returned, not only is the fun returned but the entire closure (fun
27+
y + its lexical scope) is returned and put inside z. So when z is used
28+
somewhere else in program, it still remembers var a inside x()
29+
- Closure is a very powerful concept of JS, just because this function remembers
30+
things even if they are not in their lexical scope
2531

2632
### Uses of Closure
27-
Module Design Pattern, Currying, Functions like once(fun that can be run only once), memoize, maintaining state in async world, setTimeout, iterators...
33+
34+
Module Design Pattern, Currying, Functions like once(fun that can be run only
35+
once), memoize, maintaining state in async world, setTimeout, iterators...

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /