Skip to content

Instantly share code, notes, and snippets.

@Calerme
Created May 16, 2018 07:53
Show Gist options
  • Save Calerme/e406a0bfef7cc8ebbd01d02496811ba6 to your computer and use it in GitHub Desktop.
Save Calerme/e406a0bfef7cc8ebbd01d02496811ba6 to your computer and use it in GitHub Desktop.
Function.prototype.bind polyfill
(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