Last active
October 19, 2015 16:02
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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