Skip to content

Instantly share code, notes, and snippets.

@cianclarke
Last active December 16, 2015 20:10
Show Gist options
  • Save cianclarke/5490830 to your computer and use it in GitHub Desktop.
Save cianclarke/5490830 to your computer and use it in GitHub Desktop.
Count retains it's value
var counter = function(count){
console.log("Count is " + count);
return {
getNext: function(){
return ++count;
}
};
}
myCounter = counter(0);
console.log(myCounter.getNext());
console.log(myCounter.getNext());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment