Skip to content

Instantly share code, notes, and snippets.

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