Function.prototype.bind=function(context){ if(typeofthis !=='function'){ thrownewError("Function .prototype.bind-what is trying to be bound is not callable") } var self=this; var args=Array.prototype.slice.call(arguments,1); var fNOP=function(){}; var fBound=function(){ var bindArgs=Array.prototype.slice.call(arguments); return self.apply(thisinstanceof fNOP?this:context,args.concat(bindArgs)); } fNOP.prototype=this.prototype; fBound.prototype=new fNOP(); return fBound;