Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array includes with filter vs indexOf with splice
(version: 0)
Comparing performance of:
includes + filter vs indexOf + splice
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; for (var i = 0; i < 10000; i++) { arr.push(i); } var itemToRemove = arr[Math.floor(Math.random() * 10000)]
Tests:
includes + filter
const item = arr.includes(itemToRemove); if(item) { const result = arr.filter(el => el !== item) }
indexOf + splice
const item = arr.indexOf(itemToRemove); if(item !== -1) { const result = arr.splice(item, 1) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
includes + filter
indexOf + splice
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!
Related benchmarks:
Remove an item from array; indexOf + splice vs filter
Remove an item from array; indexOf + splice vs filter 2
Remove an item from array; indexOf + splice vs filterasddsaasd
test slice with indexOf vs filter
splice vs filter array
Comments
Confirm delete:
Do you really want to delete benchmark?