Fastest way to delete an item from array (v2)

Revision 2 of this benchmark created on


Setup

function *gen() {
	for (let i = 0; i < 1000; i++)
		yield `test${i}val`
}

let arr = new Array(...gen())
const lookup = 'test699val'

Test runner

Ready to run.

Testing in
TestOps/sec
Using delete-indexOf and flat
delete arr[arr.indexOf(lookup)]
arr = arr.flat()
ready
Using filter
arr = arr.filter((val) => val !== lookup)
ready
Using toSpliced
arr = arr.toSpliced(arr.indexOf(lookup), 1)
ready

Revisions

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