1.filter---返回新数组(筛选)
var thenew = [1,2,3,4,5]; var theold = [4,3,2,1]; var thefilter = thenew.filter( i => theold.indexOf(i) >= 0 ); console.log(thefilter)
打印结果:(可以排序)
2.map---返回新数组(处理数组数据,每一项运算)
var thenewlist = [ {id:0,name:'aaa'}, {id:1,name:'bbb'}, {id:2,name:'ccc'}, {id:3,name:'ddd'}, {id:4,name:'eee'}, {id:5,name:'fff'}, ]; var theoldlist = thenewlist.map(v => v.id) console.log(theoldlist);
3.every---返回布尔值(每一项判断) 一假即假
4.some---返回布尔值(符合项判断) 一真即真
5.reduce---返回叠加值
6.find---返回第一个符合项,否则undefinded
7.fill---填充原数组(返回新数组)