Created
October 25, 2013 10:20
-
-
Save nathggns/7152556 to your computer and use it in GitHub Desktop.
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
/** | |
* Returns a function that uses it's first argument as the context | |
* for a callback | |
* @param {Function} callback The callback to call | |
* @return {Function} | |
*/ | |
function context(callback) { | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
var context = args.shift() || this; | |
return callback.apply(context, args); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment