splice vs length

Benchmark created on


Setup

const length = 1000;
const array1 = new Array(length);
const array2 = new Array(length);

for (let i = 0; i < length; ++i) {
  array1[i] = true;
  array2[i] = true;
} 

Test runner

Ready to run.

Testing in
TestOps/sec
length = 0
array1.length = 0;
array1.push(...array2);
ready
splice()
array1.splice(0, Infinity, ...array2);
ready

Revisions

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