利用ES5的filter高阶函数来实现
var arr =[1,2,3,4,5,6,7,17,27,21,22,28......100],
r = arr.filter(function(x){
return (x % 10 == 7|| x % 7 == 0);
});
alert(r);//[7,14,17,21,27,28..........97]
时间: 2024-12-09 06:31:43
利用ES5的filter高阶函数来实现
var arr =[1,2,3,4,5,6,7,17,27,21,22,28......100],
r = arr.filter(function(x){
return (x % 10 == 7|| x % 7 == 0);
});
alert(r);//[7,14,17,21,27,28..........97]