Last active
July 11, 2016 22:33
-
-
Save hunan-rostomyan/fee1e8854f3f1f78ca48a1e99bc8cb9e to your computer and use it in GitHub Desktop.
Stateful Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var called = (function() { | |
var count = 0; | |
return function() { | |
count++; | |
console.log(`Called : ${count}`); | |
}; | |
}()); | |
called(); //=> Called : 1 | |
called(); //=> Called : 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let called = (() => { | |
let count = 0; | |
return () => { | |
count++; | |
console.log(`Called : ${count}`); | |
}; | |
})(); | |
called(); //=> Called : 1 | |
called(); //=> Called : 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment