簡體   English   中英

根據索引從其他數組中刪除數組

[英]Remove array based on index from other array

我想根據其他數組arr2的索引刪除數組arr arr2可以有任何長度。

預計 Output

["test9495","test93992"]

 var arr = ["test234", "test9495", "test234", "test93992", "test234"]; var arr2 = [0, 2, 4]; console.log(arr.splice(arr2,arr2.length)) console.log(arr)

const arr = ["test234", "test9495", "test234", "test93992", "test234"];
const arr2 = [0, 2, 4];
const arr3 = arr.filter((item, index) => arr2.indexOf(index) === -1);
console.log(arr3);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM