Function.prototype.bind = function(oThis) { if (typeofthis !== 'function') { thrownewTypeError('Function.prototype.bind - what is trying to be bound is not callable') } var fToBind = this var fNOP = function() {} var args = Array.prototype.slice.call(arguments, 1) // 调用 arguments 数组的 slice 方法 var fBound = function() { // this instanceof fBound 说明返回的 fBound 被当作 new 时的构造函数调用 return fToBind.apply(thisinstanceof fBound ? this : oThis, // 获取调用 fBound 时的传参 args.concat(Array.prototype.slice.call(arguments))) }