Tests:
  • Keep items that are not supposed to be removed

    x
     
    let items = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }];
    const itemsToRemove = [{ id: 2 }, { id: 4 }, { id: 5 }];
    items = items.filter(item => !itemsToRemove.find(remove => remove.id === item.id));
  • Remove items that are supposed to be removed

     
    let items = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }];
    const itemsToRemove = [{ id: 2 }, { id: 4 }, { id: 5 }];
    itemsToRemove.forEach(remove => {
        const index = items.findIndex(item => item.id === remove.id);
        items.splice(index, 1);
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Keep items that are not supposed to be removed
    Remove items that are supposed to be removed

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Firefox 75 on Ubuntu
View result in a separate tab
Test name Executions per second
Keep items that are not supposed to be removed 2458974.8 Ops/sec
Remove items that are supposed to be removed 1247964.5 Ops/sec