Skip to content

Instantly share code, notes, and snippets.

@JoanClaret
Created September 28, 2015 14:35
Show Gist options
  • Save JoanClaret/596dd0e9187aab287f1a to your computer and use it in GitHub Desktop.
Save JoanClaret/596dd0e9187aab287f1a to your computer and use it in GitHub Desktop.
"use strict";
var myClosure = (function outerFunction() {
var hidden = 1;
return {
inc: function innerFunction() {
return hidden++;
}
};
}());
myClosure.inc(); // returns 1
myClosure.inc(); // returns 2
myClosure.inc(); // returns 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment