JavaScript array splice() performance

Benchmark created on


Setup

let numbers= Array.from({length: 100000}, () => Math.floor(Math.random() * 100));

Test runner

Ready to run.

Testing in
TestOps/sec
Use splice() to add 10 elements at the end of the array
numbers.splice(numbers.length, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
ready
Use push() to add 10 elements at the end of the array
numbers.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
ready
Use splice() to remove 10 elements from the end of the array
numbers.splice(numbers.length - 10, 10);
ready
Use pop() to remove 10 elements from the end of the array
for (let index = 0; index < 10; index++) {
  numbers.pop();
}
ready

Revisions

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