我有一些包含数组的compllex组件
this.SomeComponent.subArray
SomeComponent:model1;
model1定义:
someString1:string;
someString2:string;
someString3:string;
subArray[]
model2定义:
someString22:string;
someString23:string;
someString24:string;
现在,如果我console.log(JSON.stringify(this.SomeComponent.subArray));我得到:
SomeComponent[{"someString22":"one","someString23":"yellow","someString24":"water",},
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]
现在我的任务是删除具有subArray
的someString23==red
部分。因此,当我下次控制台日志时,我只能得到此
SomeComponent[
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]
我该怎么做?
使用如下过滤方法:-
console.log(subArray.filter((item) => item["someString23"]!==red));