我發現這個代碼,我不明白註釋塊的目的參數:爲什麼註釋塊中的第二個函數參數?只是好奇
if (!Array.prototype.some)
{
Array.prototype.some = function(fun /*, thisp*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this && fun.call(thisp, this[i], i, this))
return true;
}
return false;
};
}
在我看來,這可能是正常的第二個參數,該行可以再刪除:
var thisp = arguments[1];
你可以問問原始作者的代碼? –
夥計,這只是一個評論!它沒有意義,它只是在那裏!誰知道他想用這個參數做什麼? – gdoron
似乎這個問題可能會更好地指向有問題的代碼的作者... [編輯添加:哦,看,其他人先到那裏,並說同樣的。我會在這裏留下這個提醒自己刷新之前評論:-) –