push vs new array

Benchmark created by callumacrae on


Setup

let startArray = [];
  for (let i = 0; i < 1000; i++) {
    startArray.push(i);
  }

Test runner

Ready to run.

Testing in
TestOps/sec
push
startArray.push('test')
ready
new array
startArray = [...startArray, 'test']
ready

Revisions

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

  • Revision 1: published by callumacrae on