spliceOne

Benchmark created on


Setup

const arr = ['a', 'b', 'c', 'd', 'e', 'f']

function spliceOne (list, index) {
  const length = list.length - 1
  while (index++ < length) list[index] = list[index]
  list.pop()
}

function spliceUnordered (list, index) {
    if (index === list.length - 1) {
        list.pop()
        return
    }
    list[index] = list.pop()
  }

Test runner

Ready to run.

Testing in
TestOps/sec
native
arr.splice(1,1)
ready
spliceOne
spliceOne(arr, 1)
ready
spliceUnordered
spliceUnordered(arr, 1)
ready

Revisions

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