[英]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.