Rumah > Soal Jawab > teks badan
let arr1 = ['a','b','c','d'];
let arr2 = [1,4];//通过这个数组过滤掉arr1中索引为1跟4的选项
Bolehkah ini dicapai menggunakan penapis
给我你的怀抱2017-05-19 10:45:00
let arr1 = ['a','b','c','d'];
let arr2 = [1,4];
arr1.filter((value,index)=>{
return arr2.indexOf(index) === -1;
});
怪我咯2017-05-19 10:45:00
arr1.filter(function(){
for(let i = 0 , i < arr2.length, i++){
return arr1[arr2[i]]
}
})
过去多啦不再A梦2017-05-19 10:45:00
let newArr = arr1.filter((el, index, array) => {
return arr2.indexOf(index) === -1
})
let newArr = arr1.filter((el, index, array) => {
return !arr2.includes(index)
})
给我你的怀抱2017-05-19 10:45:00
arr1 = arr1.filter((e,i) => arr2.indexOf(i)===-1)
Subskrip bermula dari 0