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