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个参数,但是里边的判断语句像下边这句
case 4: return function(accumulator, value, index, collection) { return func.call(context, accumulator, value, index, collection); };
这个内部函数的accumulator, value, index, collection这些参数是从哪里来的呢?
德玛西亚99
相关分类