亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

js傳參的問題

js傳參的問題

慕田峪4524236 2018-08-14 09:09:19
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這些參數是從哪里來的呢?
查看完整描述

1 回答

?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

它返回的是一個函數本身,這個返回的函數肯定是要拿到別的地方運行的,這些參數當然就是運行的時候輸入的啦。


查看完整回答
反對 回復 2018-09-21
  • 1 回答
  • 0 關注
  • 507 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號