来自:http ://ejohn.org/apps/learn/#2
Function.prototype.bind = function(){
var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function(){
return fn.apply(object,
args.concat(Array.prototype.slice.call(arguments)));
};
};
谁能告诉我为什么需要第二次退货(在 fn.apply 之前)?
另外,谁能解释为什么 args.concat 是必要的?为什么不将其重写为:
fn.apply(object, args)
代替
return fn.apply(object,
args.concat(Array.prototype.slice.call(arguments)));