Skip to content

Instantly share code, notes, and snippets.

@jed
Forked from 140bytes/LICENSE.txt
Created May 10, 2011 16:06
Show Gist options
  • Save jed/964765 to your computer and use it in GitHub Desktop.
Save jed/964765 to your computer and use it in GitHub Desktop.
bind functions cross-browser
function(
a, // the function to be bound
b, // (placeholder)
c // (placeholder)
){
b = [].slice.call( // cache the
arguments, 1 // original arguments
);
c = this; // and the context.
return function() { // return a function
b.unshift.apply( // that prepends the original arguments
arguments, b // to the current arguments, and
);
return a.apply( // calls the original function
c, arguments // with the original context and new arguments
)
}
}
function(a,b,c){b=[].slice.call(arguments,1);c=this;return function(){b.unshift.apply(arguments,b);return a.apply(c,arguments)}}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "bind",
"keywords": ["bind", "function", "functional", "curry"]
}
@reMekElek
Copy link

function(a,b,c,d){b=[].slice.call(d=arguments,1);c=this;return function(){b.unshift.apply(d,b);return a.apply(c,d)}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment