Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
Created July 8, 2018 03:10
Show Gist options
  • Save wizard04wsu/aa2537367ad13e20f6c8fb24b6998806 to your computer and use it in GitHub Desktop.
Save wizard04wsu/aa2537367ad13e20f6c8fb24b6998806 to your computer and use it in GitHub Desktop.
function bind(targetFunction, thisArg){
"use strict";
var boundArgs = Array.prototype.slice.call(arguments, 2);
try{
return Function.prototype.bind.apply(targetFunction, [thisArg].concat(boundArgs));
}catch(e){
function boundFunction(){
return targetFunction.apply(thisArg, boundArgs.concat(arguments));
}
boundFunction.toString = function toString(){ return targetFunction.toString(); };
Object.defineProperties(boundFunction, { 'toString':{ enumerable:false } });
return boundFunction;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment