js陣列過濾

君子笑而不语發表於2024-10-16

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

相關文章