遍历数组的方法

forEach()方法
语法:array.forEach(function(item,index,array),thisvalue)

参数:function(item,index,array)数组中每项都会调用的函数

原理:

function forEach(array,fn) {
    for(let i=0;i        fn(array[i],i,array)
    }
}

你可能感兴趣的:(遍历数组的方法)