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: Notes/10-Closures.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ console.log(z); // value of z is entire code of function y.
22
22
When functions are returned from another fun, they still maintain their lexical scope.
23
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
24
somewhere else in program, it still remembers var a inside x()
25
+
- Closure is a very powerful concept of JS, just because this function remembers things even if they are not in their lexical scope
25
26
26
27
### Uses of Closure
27
28
Module Design Pattern, Currying, Functions like once(fun that can be run only once), memoize, maintaining state in async world, setTimeout, iterators...
0 commit comments