jQuery,数组过滤出某一值,返回新数组。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41229582/article/details/81530169
var array=[1,2,3,5,1,10,15,2,5,12,2];
var newArray= $.grep(array,function (n, i){
     if(data[i]== 2){
         return n;
     }
 },true);

console.log(newArray);        // [1,3,5,1,10,15,5,12];

猜你喜欢

转载自blog.csdn.net/qq_41229582/article/details/81530169