Skip to content

Commit a5eaf03

Browse files
Fixed typos in Closure
1 parent e0ae226 commit a5eaf03

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ function getTicker () {
168168
tickTock(); //returns 1
169169
tickTock(); //returns 2
170170
```
171-
The function getTimer() returns a function(internally called ticker), lets store it in a variabke called tickTock.
171+
The function getTicker() returns a function(internally called ticker), lets store it in a variabke called tickTock.
172172

173-
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.
173+
Ideally, when the function getTicker finishes execution, its scope, with local variable tick should 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.
174174

175175
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.
176176

0 commit comments

Comments
 (0)