Filter vs toSpliced

Benchmark created on


Setup

var items = Array.from({length: 1e3}).map((_, index) => index)
var lastItem = items.at(-1)

Test runner

Ready to run.

Testing in
TestOps/sec
Filter
var availableItems = items.filter(item => item != lastItem)
ready
toSpliced
var availableItems = items.toSpliced(items.indexOf(lastItem), 1)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.