Slice and assign vs splice in place (v3)

Revision 3 of this 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

Test runner

Ready to run.

Testing in
TestOps/sec
.slice(n)
let list = Array.from({ length: 10_000 }, Math.random)

list = list.slice(500)
ready
.splice(0, n)
const list = Array.from({ length: 10_000 }, Math.random)

list.splice(0, 500)
ready

Revisions

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