Created
May 16, 2018 07:53
-
-
Save Calerme/e406a0bfef7cc8ebbd01d02496811ba6 to your computer and use it in GitHub Desktop.
Function.prototype.bind polyfill
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 () { | |
function _bind(context) { | |
var fn = this; | |
var _this = context; | |
var bindArgs = Array.prototype.slice.call(arguments, 1); | |
return function () { | |
var args = Array.prototype.slice.call(arguments); | |
args = bindArgs.concat(args); | |
return fn.apply(_this, args); | |
} | |
} | |
Function.prototype.bind = Function.prototype.bind ? Function.prototype.bind : _bind; | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment