var optimizeCb = function(func, context, argCount) { if (context === void 0) return func;
switch (argCount == null ? 3 : argCount) { case 1: return function(value) { return func.call(context, value);
}; case 2: return function(value, other) { return func.call(context, value, other);
}; case 3: return function(value, index, collection) { return func.call(context, value, index, collection);
}; case 4: return function(accumulator, value, index, collection) { return func.call(context, accumulator, value, index, collection);
};
} return function() { return func.apply(context, arguments);
};
};我不太理解optimizeCb只傳入了3個參數(shù),但是里邊的判斷語句像下邊這句case 4: return function(accumulator, value, index, collection) { return func.call(context, accumulator, value, index, collection);
};這個內(nèi)部函數(shù)的accumulator, value, index, collection這些參數(shù)是從哪里來的呢?
js傳參的問題
慕田峪4524236
2018-08-14 09:09:19