Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Created November 15, 2012 01:47
Show Gist options
  • Select an option

  • Save WebReflection/4076138 to your computer and use it in GitHub Desktop.

Select an option

Save WebReflection/4076138 to your computer and use it in GitHub Desktop.
asImplicitCall() to avoid usage of `fn.call()` everywhere
/*! (C) WebReflection - Mit Style License */
(function(FunctionPrototype){
var
bind = FunctionPrototype.bind || function () {
var callback = this;
return function bind() {
return callback.apply(this, arguments);
};
},
call = FunctionPrototype.call
;
bind = bind.call(call, bind);
FunctionPrototype.asImplicitCall = function asImplicitCall() {
return bind(call, this);
};
}(Function.prototype));
// var toString = {}.toString.asImplicitCall();
// toString([]); // [object Array]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment