Slice and assign vs splice in place

Benchmark created on


Description

Compare removing leading array elements with assigning the variable to the slice of the old one without the leading elements, vs mutating the array in place by removing the leading elements from it

Setup

window.list = Array.from({ length: 10_000 }, Math.random)

Test runner

Ready to run.

Testing in
TestOps/sec
.slice(n)
window.list = window.list.slice(500)
ready
.splice(0, n)
window.list.splice(0, 500)
ready

Revisions

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