Concat -vs- Spread Operator

Benchmark created on


Description

This test compares the performance of a native .concat to that of a spread operator.

Setup

const arrOne = Array
 				.from({length: 5000})
 				.map( it => (
 					{
 						firstVal: Math.random() * 15, 
 						secondVal: Math.random() * 6 
					}))

const arrTwo = Array
 				.from({length: 5000})
 				.map( it => (
 					{
 						firstVal: Math.random() * 15, 
 						secondVal: Math.random() * 6 
					}))

Test runner

Ready to run.

Testing in
TestOps/sec
Array.concat
const combinedValues = arrOne.concat(arrTwo)
ready
Spread Operator
const combinedValues = [...arrOne, ...arrTwo]
ready

Revisions

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