Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

reMekElek commented Aug 16, 2011

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
You can’t perform that action at this time.