Filter and delete filtered elements in an array

前端 未结 6 1492
遥遥无期
遥遥无期 2020-12-09 16:32

I want to remove specific elements in the original array (which is var a). I filter() that array and splice() returned new array. but

6条回答
  •  青春惊慌失措
    2020-12-09 17:23

    another way is filtering in two list like below:

    const originalList = [{condition:true}, {condition: false}, {condition: true}];
    
    // wished lists
    const listWithTrue = originalList.filter(x=>x.condition);
    const listWithFalse = originalList.filter(x=>!x.condition); // inverse condition
    

提交回复
热议问题