文章已阅读
 

1.数组.map

map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。

map() 方法按照原始数组元素顺序依次处理元素。

注意: map() 不会对空数组进行检测。

注意: map() 不会改变原始数组。

用法:array.map(function(currentValue,index,arr), thisValue)

currentValue 必须。当前元素的值
index 可选。当前元素的索引值
arr 可选。当前元素属于的数组对象

2.数组.forEach()方法

用法:array.forEach(function(currentValue, index, arr), thisValue)

注意:forEach() 方法用于调用数组的每个元素,并将元素传递给回调函数。

forEach() 对于空数组是不会执行回调函数的。

使用举例:

1
2
3
this.orderlist.forEach((value, index) => {
value["fmoduleName"] = fmoduleName;
});
2022-10-13

浏览 |

© 2023 南疆 with help from Hexo and Twitter Bootstrap. Theme by Freemind.

container-narrow -->