Skip to content

Commit e0ae226

Browse files
Fixed typos in Closure
1 parent d1f6c16 commit e0ae226

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const add2 = curriedSum(2) // (b) => 2 + b
145145
add2(10) // 12
146146

147147
```
148+
148149
##Closure
149150

150151
A very simplistic definition - A closure is a way of accessing a variable outside its scope.
@@ -167,13 +168,11 @@ function getTicker () {
167168
tickTock(); //returns 1
168169
tickTock(); //returns 2
169170
```
170-
The function getTimer() returns a function(internally called ticker), lets call it tickTock.
171+
The function getTimer() returns a function(internally called ticker), lets store it in a variabke called tickTock.
171172

172173
Ideally, when the getTimer finishes execution, its scope, with local variable tick should also not be accessible. But, it returns 1, 2, 3.. on calling tickTock(). This simply means that, somewhere it keeps a track of the variable tick.
173174

174-
Lexical scoping is the reason why it is able to find the value of tick, the private variable of the parent which has finished executing. This value is called a closure. The stack along with the lexical scope of the function is stored and upon re-execution same stack is restored.
175-
176-
175+
Lexical scoping is the reason why it is able to find the value of tick - the private variable of the parent which has finished executing. This value is called a Closure. The stack along with the lexical scope of the function is stored and upon re-execution same stack is restored.
177176

178177
## Auto Currying
179178
Transforming a function that takes multiple arguments into one that if given less than its correct number of arguments returns a function that takes the rest. When the function gets the correct number of arguments it is then evaluated.

0 commit comments

Comments
 (0)