Why/How _foreach 中的 lodash“[iteratee=_.identity](函数)”是否有 'mystery' 第三个参数?
Why/How does a lodash "[iteratee=_.identity] (Function)" in _foreach have a 'mystery' third param?
我今天第一次掌握了 lodash.js 的窍门,发现您可以在迭代器函数中访问 'value' 'index' 和 'list'。
我在使用 _.foreach 函数时遇到了这个问题。
例如:
_.forEach(oMyArray, function(value, index, list){
...
})
但是 API 在处理对象时只指定了 2 个参数 "n" 和 "key"。
为什么没有提到第三个?
?您的 API link 列出了三个参数:
The iteratee is bound to thisArg and invoked with three arguments:
(value, index|key, collection)
我今天第一次掌握了 lodash.js 的窍门,发现您可以在迭代器函数中访问 'value' 'index' 和 'list'。
我在使用 _.foreach 函数时遇到了这个问题。
例如:
_.forEach(oMyArray, function(value, index, list){
...
})
但是 API 在处理对象时只指定了 2 个参数 "n" 和 "key"。
为什么没有提到第三个?
?您的 API link 列出了三个参数:
The iteratee is bound to thisArg and invoked with three arguments: (value, index|key, collection)