标签:i++ family 遍历 mil app bsp apple code foreach
数组遍历的四种方法:
方法一:
var arr=["apple","red","5"]; for(var i=0;i<arr.length;i++){ console.log("arr["+i+"]: "+arr[i]) }
方法二:
for(var i in arr){ console.log(arr[i]) }
方法三:es5 v:值 i:索引
arr.forEach(function(v,i){ console.log("v: "+v) console.log("i: "+i) })
方法四:es6
for(var v of arr){ console.log(v) }
标签:i++ family 遍历 mil app bsp apple code foreach
原文地址:https://www.cnblogs.com/tizi/p/11063687.html