Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created April 17, 2014 16:51
Show Gist options
  • Save zapthedingbat/10997535 to your computer and use it in GitHub Desktop.
Save zapthedingbat/10997535 to your computer and use it in GitHub Desktop.
Creates a function that executes with the given context and pushes the original context to the first argument of the function.
// Creates a function that executes with the given context and pushes the original context to the first argument of the function.
unshiftContext: function(func, thisArg) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.unshift(this);
func.apply(thisArg, args);
};
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment