有哪些遍历数组的方式
参考答案
for (let i = 0; i < len; i++):最快,可中断for...of:按值遍历,支持 break/continue,可用迭代器for...in:遍历索引键(不推荐用于数组,会含自定义属性)forEach:无返回值,不可中断map/filter/reduce/reduceRightsome/every/find/findIndex:可提前结束keys()/values()/entries()+ for...ofwhile/do...while手动索引flatMap(遍历 + 展平一层)