adding element to the array start

Benchmark created by avernikoz on


Test runner

Ready to run.

Testing in
TestOps/sec
array with spread
// # first case

const b = 'element'
const arr = new Array(1000).fill(undefined)

const c = [b, ...arr]
ready
array with concat
// # second case

const b = 'element'
const arr = new Array(1000).fill(undefined)

const c = [b].concat(arr)
ready
array with unshift
// # third case

const b = 'element'
const arr = new Array(1000).fill(undefined)

arr.unshift(b)
const c = arr.slice()
ready

Revisions

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

  • Revision 1: published by avernikoz on