前端------Filter

其实数组的很多函数需要的参数都是一样的

arr.fun((item,index,arr)=>{

    item:数组的元素

    index:数组元素在的位置

    arr:整个数组
})
Filter 是数组的一个用法,用来返回一个数组,满足特定条件的数组中的元素

let arr=[1,2,3,4];

let newArr=arr.filter((item,index,arr)=>{

console.log("数组元素${item}");

console.log("元素位置${index}");

console.log("整个数组${arr}");

return item>2;

})

案例:





    
    
    
    Document
    


你可能感兴趣的:(前端系列---从入门到深化,html,vue)