Created
September 28, 2013 11:51
-
-
Save rikuba/6741315 to your computer and use it in GitHub Desktop.
patch Function.prototype.apply LICENSE: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
This file contains 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
(function () { | |
try { | |
Array.apply(null, {}); | |
return; | |
} catch (e) { } | |
var toString = Object.prototype.toString, | |
arrayType = '[object Array]', | |
_apply = Function.prototype.apply, | |
slice = /*@cc_on @if (@_jscript_version <= 5.8) | |
function () { | |
var a = [], i = this.length; | |
while (i-- > 0) a[i] = this[i]; | |
return a; | |
}@else@*/Array.prototype.slice/*@end@*/; | |
Function.prototype.apply = function apply(thisArg, argArray) { | |
return _apply.call(this, thisArg, | |
toString.call(argArray) === arrayType ? argArray : slice.call(argArray)); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment