js数组过滤

君子笑而不语 / 2024-10-21 / 原文

 

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