|
@@ -1,7 +1,7 @@
|
|
<!--
|
|
<!--
|
|
* @Author: your name
|
|
* @Author: your name
|
|
* @Date: 2021-08-20 16:17:21
|
|
* @Date: 2021-08-20 16:17:21
|
|
- * @LastEditTime: 2021-08-24 11:28:59
|
|
|
|
|
|
+ * @LastEditTime: 2021-08-24 11:31:49
|
|
* @LastEditors: Please set LastEditors
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description:
|
|
* @Description:
|
|
* @FilePath: \md-\js\合并数组中的key值.md
|
|
* @FilePath: \md-\js\合并数组中的key值.md
|
|
@@ -113,10 +113,12 @@ const res = [...map.values()]
|
|
- `currentValue`当前值,当前循环到的数组元素的实际值
|
|
- `currentValue`当前值,当前循环到的数组元素的实际值
|
|
- `index `下标,当前循环到的数组元素的下标值
|
|
- `index `下标,当前循环到的数组元素的下标值
|
|
- `array`原始数组,当前循环的原始数组
|
|
- `array`原始数组,当前循环的原始数组
|
|
-
|
|
|
|
|
|
+> [!tip]
|
|
|
|
+> 一个偏向于官方风格的示例,用来求数组中的和
|
|
```js
|
|
```js
|
|
[0,1,2,3].reduce((accumulator,currentValue,index,array)=>{
|
|
[0,1,2,3].reduce((accumulator,currentValue,index,array)=>{
|
|
console.log(`accumulator:${accumulator}\ncurrentValue:${currentValue}\nindex:${index}`)
|
|
console.log(`accumulator:${accumulator}\ncurrentValue:${currentValue}\nindex:${index}`)
|
|
|
|
+ return accumulator + currentValue
|
|
},-1)
|
|
},-1)
|
|
```
|
|
```
|
|
|
|
|