怎样快速而优雅地遍历JavaScript数组
Opened this issue · 0 comments
longyangxing commented
最近现场反馈了一个bug,由于Indexof遍历数据量过大,造成IE卡死
未优化代码
var array = [0,1,2,3,4,5,6,7,8,9];
for(var val in array) {
fn(val)
}
另外一种常见写法
var array = [0,1,2,3,4,5,6,7,8,9];
for(var i=0; i < array.length; i++){
fn(array[i])
}