ES6经常使用的数组方法

filter方法,返回新数组,遍历的元素,哪一项返回true哪一项存放在newArr新数组中数组 var a = [1,2,3,4]函数 let newArr = a.filter(function(item,index){ if(item > 2){ return true } })回调函数 console.log(newArr)//[3,4]it forEach()和map()方法 二者相同点
相关文章
相关标签/搜索