Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11 from gibletto/master
Added native Function.prototype.bind rendition
  • Loading branch information
David Mark committed Mar 6, 2012
2 parents b5f1134 + 40ba75e commit 6115d88
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions functions/bind/rendition2.js
@@ -0,0 +1,7 @@
var bind;

if(Function.prototype.bind){
bind = function(fn, thisObject) {
return fn.bind.apply(fn, Array.prototype.slice.call(arguments, 1));
};
}
23 changes: 23 additions & 0 deletions functions/bind/rendition3.js
@@ -0,0 +1,23 @@

var bind;
if(Function.prototype.bind){
bind = function(fn, thisObject) {
return fn.bind.apply(fn, Array.prototype.slice.call(arguments, 1));
};
}
else {
if(canCall) {
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 6115d88

Please sign in to comment.