Skip to content

Instantly share code, notes, and snippets.

@bekapod
Created November 28, 2016 11:29
Show Gist options
  • Save bekapod/23efdf53ddbb73c193c52085eb430a41 to your computer and use it in GitHub Desktop.
Save bekapod/23efdf53ddbb73c193c52085eb430a41 to your computer and use it in GitHub Desktop.
JS: returning functions
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