Closed. This question is not reproducible or was caused by typos。它当前不接受答案。












想改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。

5年前关闭。



Improve this question




可以说我有:
var someValues = [1, 'abc', 3, 'sss'];

如何使用箭头函数遍历每个函数并对每个值执行操作?

最佳答案

简而言之:

someValues.forEach((element) => {
    console.log(element);
});

如果您关心索引,那么可以传递第二个参数来接收当前元素的索引:
someValues.forEach((element, index) => {
    console.log(`Current index: ${index}`);
    console.log(element);
});

关于javascript - 使用箭头功能循环遍历值数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33763768/

10-11 22:43
查看更多