Js数组的map,filter,reduce,every,some方法

var arr=[1,2,3,4,5,6];

res = arr.map(function(x){return x*x})

[1, 4, 9, 16, 25, 36]

res = arr.filter(function(x){return x<3})

[1, 2]

res = arr.reduce(function(a,b){return a+b})

21

res = arr.every(function(x){return x>7})

false

res = arr.some(function(x){return x<3})

true

原文地址:https://www.cnblogs.com/413xiaol/p/6765651.html