Created
November 28, 2016 11:29
-
-
Save bekapod/23efdf53ddbb73c193c52085eb430a41 to your computer and use it in GitHub Desktop.
JS: returning functions
This file contains hidden or 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
function setup() { | |
var count = 0; | |
return function() { | |
return ++count; | |
}; | |
} | |
var next = setup(); | |
next(); // 1 | |
next(); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment