js数组过滤

 

a=[5,4,3,2,1];
everyother=a.filter(function(x,i){return i%2==0});
console.log(everyother,a)  //[4, 2] [5, 4, 3, 2, 1]

 

 

原文链接:https://blog.csdn.net/yjf997234900/article/details/38312885

 

posted @ 2024-10-16 19:58  君子笑而不语  阅读(6)  评论(0编辑  收藏  举报