Fastest way to delete an item from array (v3)

Revision 3 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
Using splice
arr.splice(arr.indexOf(lookup), 1)
ready

Revisions

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