js 数组遍历

2018-10-22  本文已影响0人  gis杭州

烂大街的写法:

var testArr = [2,3,4,"f","u","c"];
for (var i= 0;i<testArr.length;i++){
  console.log(testArr[i])
}
image.png

数组内置的forEach方法

let testArr1 = [2,3,4,"f","u","c"];
testArr1.forEach(single=>{
  console.log(single);
})

image.png
上一篇 下一篇

猜你喜欢

热点阅读