foreach怎么用
来源:2-8 首页-商家列表(2)
所向无一
2019-07-29 23:13:08
1
1回答
同学你好,
forEach() 方法用于调用数组的每个元素,并将元素传递给回调函数。
语法:array.forEach(function(currentValue, index, arr), thisValue)
参数:
function(currentValue, index, arr) 必需, 数组中每个元素需要调用的函数。
currentValue 必需。当前元素
index 可选。当前元素的索引值。
arr 可选。当前元素所属的数组对象。
thisValue 可选。传递给函数的值一般用 "this" 值。如果这个参数为空, "undefined" 会传递给 "this" 值
例如:
自己可以测试下,祝学习愉快!
相似问题