📜  遍历数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:13.610000             🧑  作者: Mango

代码示例6
var arr = [1,2,3,4,5,6,7,8];

// Uses the usual "for" loop to iterate
for(var i= 0, l = arr.length; i< l; i++){
    console.log(arr[i]);
}

console.log("========================");

//Uses forEach to iterate
arr.forEach(function(item,index){
    console.log(item);
});