Test name | Executions per second |
---|---|
Filter | 24557768.0 Ops/sec |
Splice | 13945260.0 Ops/sec |
let array = [1,2,3,4,5,6,7,8]
const toFilter = [2,4,7]
array = array.filter(item => !toFilter.includes(item));
let array = [1,2,3,4,5,6,7,8]
const toRemove = [2,4,7]
for (const removeable of toRemove) {
const index = array.indexOf(removeable);
if (index > 0) array.splice(index,1);
}