如何在迭代过程中访问数组中元素的索引?
How do you access the index of an element in an array during iteration?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: easy
分类: Operators & Control Flow
标签: javascript
参考答案摘要
TL;DR 要在迭代过程中访问数组中元素的索引,可以使用 forEach 、 map 、 for...of 与 entries 或传统的 for 循环等方法。例如,使用 forEach : const array = ['a', 'b', 'c']; array.forEach((element, index) => { console....
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。