Shallow array clone (v2)

Revision 2 of this benchmark created on


Setup

const array = []
for (let i = 0; i < 1_000; i++) {
	array[i] = i
}

Test runner

Ready to run.

Testing in
TestOps/sec
Slice call without arguments
array.slice()
ready
Slice call with start argument
array.slice(0)
ready
Slice call with start and count arguments
array.slice(0, array.length)
ready
Spread inside array literal
[...array]
ready
Array.from call
Array.from(array)
ready
Concat call
array.concat()
ready
Object.values call
Object.values(array)
ready
Object.assign call
Object.assign([], array)
ready

Revisions

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