let arr =[0,2,5,4,7,8,6,5,4,9]
/**
* 1,for 循环遍历数组
*/
function forLoop(arr){
for(let i =0;i{
console.log(currentValue,index,array) // 0 0 [0, 2, 5, 4, 7, 8, 6, 5, 4, 9]
})
}
forEachLoop(arr);
/***
* map()
* 不会改变原始数组
* 不会对空数组进行检测
*/
function mapLoop(array){
array.map((currentValue,index,array)=>{
console.log(currentValue,index,array) //0 0 [0, 2, 5, 4, 7, 8, 6, 5, 4, 9]
})
}
mapLoop(arr);