Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jasonbellamy/d194790f1b2cd1214afa to your computer and use it in GitHub Desktop.
Save jasonbellamy/d194790f1b2cd1214afa to your computer and use it in GitHub Desktop.
An example of a function thats uses unneeded anonymous function wrappers.
var stateManger = function () {
var active = false;
var setState = function(state) {
active = state;
};
return {
toggle: function () {
return setState(!active);
},
setActive: function () {
return setState(true);
},
setInactive: function () {
return setState(false);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment