Skip to content

Commit

Permalink
bind rendition 3
Browse files Browse the repository at this point in the history
Created a rendition 3 for the bind method
  • Loading branch information
Ian Crowther committed Aug 1, 2012
1 parent b406610 commit 1628fcd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions functions/bind/rendition3.js
@@ -0,0 +1,27 @@
/*global canCall */

/*
Description:
Both W3C and MS implementation therefore providing the greatest browser support
*/

var bind;

if(canCall && Function.prototype.bind){
bind = function(fn, thisObject) {
return fn.bind.apply(fn, Array.prototype.slice.call(arguments, 1));
};
} else if(canCall && Array.prototype.slice) {
bind = function(fn, context) {
var prependArgs = Array.prototype.slice.call(arguments, 2);

if (prependArgs.length) {
return function() {
fn.apply(context, Array.prototype.concat.apply(prependArgs, arguments));
};
}
return function() {
fn.apply(context, arguments);
};
};
}

0 comments on commit 1628fcd

Please sign in to comment.