Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
filter vs splice + indexOf
(version: 0)
See if filter is faster than splice method for deletion
Comparing performance of:
Filter vs Splice vs Test array result
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
Filter
let array = [1,2,3,4,5,6,7,8] const toFilter = [2,4,7] array = array.filter(item => !toFilter.includes(item));
Splice
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); }
Test array result
if (array !== [1, 3, 5, 6, 8]) throw new Error("Array should be filtered")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Filter
Splice
Test array result
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?