let arr = [{type:"1"},{type:"2"},{type:"3"}]
使用for循环
for(let i=0; i<arr.length; i++){
console.log(arr[i])
if(arr[i].type=='1'){
arr.splice(i, 1);
i--;
}
}
使用forEach循环
data.result.forEach((item, index, array) => {
if (array[index].type=== "1") {
item = array.splice(index, 1);
}
});
filter遍历
var arr = [
{ id: 1, text: 'aa', done: true },
{ id: 2, text: 'bb', done: false }
]
console.log(arr.filter(item => item.done))