kindring vor 3 Jahren
Ursprung
Commit
7ae0499a83
1 geänderte Dateien mit 25 neuen und 3 gelöschten Zeilen
  1. 25 3
      js/合并数组中的key值.md

+ 25 - 3
js/合并数组中的key值.md

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-08-20 16:17:21
- * @LastEditTime: 2021-08-20 17:49:55
+ * @LastEditTime: 2021-08-23 18:04:51
  * @LastEditors: Please set LastEditors
  * @Description: 
  * @FilePath: \md-\js\合并数组中的key值.md
@@ -96,6 +96,28 @@ const res = [...map.values()]
 <!-- tabs:ends -->
 
 ## 知识点总结
-### 1. `reduce`的使用
-### 2. 解构赋值
+### 1. `reduce`的使用,[更详细的定义](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
+在js里,为array进行了部分扩展,`reduce`函数将会将数组中的每个元素执行你所提供的reduce回调函数,返回指定值
+> [!tip]
+> 这个函数中callback函数接收的参数和其他的数组函数基本一致,除了第一个参数有所不同,后续参数基本一致
+1. 参数解释
+- `callback`要执行的函数
+- `initValue`初始值
+```js
+    // @param {Function} callback 要执行的函数
+    // @param {*} initValue 初始值.可选默认为 undefined
+    Array.reduce(callback,initValue)
+```
+2. callback函数可以接收的参数
+- `accumulator`累加器,上次循环的返回值,如果是第一次循环,则值为`initValue`.
+- `currentValue`当前值,当前循环到的数组元素的实际值
+- `index `下标,当前循环到的数组元素的下标值
+- `array`原始数组,当前循环的原始数组
+```js
+[0,1,2,3].reduce((accumulator,currentValue,index,array)=>{
+
+},0)
+``` 
+
+### 2. `js`解构赋值
 ### 3. `Map`的使用