【发布时间】:2013-07-20 03:11:18
【问题描述】:
以下代码(来自 msdn)是“绑定”功能的简单实现:
/* Approximation of `Function.prototype.bind` from ES5 (without error checking) */
Function.prototype.bind = function(thisArg) {
var fn = this, args = *Array.prototype.slice.call(arguments, 1)*;
return function() {
return fn.apply(thisArg, args.concat(*Array.prototype.slice.call(arguments, 0)*));
};
};
谁能解释第一次调用 Array.prototype.slice.call 吗?我知道参数不是数组,在使用 slice 和 concat 之前需要将其转换为数组。我不明白第一次调用 - 我们在调用时不是丢失了第一个元素
Array.prototype.slice.call(arguments, 1)?
【问题讨论】:
标签: javascript