Created
November 15, 2012 01:47
-
-
Save WebReflection/4076138 to your computer and use it in GitHub Desktop.
asImplicitCall() to avoid usage of `fn.call()` everywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! (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