Skip to content

Instantly share code, notes, and snippets.

@fearphage
Created November 4, 2009 09:42
Show Gist options
  • Save fearphage/225918 to your computer and use it in GitHub Desktop.
Save fearphage/225918 to your computer and use it in GitHub Desktop.
Function.prototype.partial = (function(slice, undefined) {
return function() {
var fn = this, args = slice.call(arguments);
return function() {
var arg = 0, index, length = arguments.length;
while (((index = args.indexOf(undefined)) > -1) && (index < length)) {
args.splice(index, 1, arguments[arg++]);
}
return fn.apply(this, args);
};
};
})(Array.prototype.slice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment