spread vs explicit

Benchmark created on


Setup

const arr = Array.from({length: 50000}, () => Math.floor(Math.random() * 99999));


Test runner

Ready to run.

Testing in
TestOps/sec
case 1
const result = arr.reduce((acc, item, idx) =>{
	acc = {
		...acc,
		[idx]: item
	}	
},{})
console.log(result)
ready
case 2
const result = arr.reduce((acc, item, idx) =>{
	acc[idx] = item;
	return acc;
},{})
console.log(result)
ready

Revisions

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