js之数组遍历的方法
1.使用for循环var arr1 = [1, 2, 3, 4, 5];// 1.for循环for(var i=0; i<arr1.length; i++){ console.log(arr1[i]);}2.for ofvar arr1 = [1, 2, 3, 4, 5];for(var item of arr1){ console.log(item);}3.forEach:不可以停止或者跳出循环// 3.forEach,不可以停止或者跳出循环ar
原创
2020-05-12 10:45:10 ·
289 阅读 ·
0 评论