Reduce - mutate vs new object (v2)

Revision 2 of this benchmark created on


Setup

const values = new Array(1_0).fill(true).map(v => Math.random())

Test runner

Ready to run.

Testing in
TestOps/sec
Mutate
values.reduce((acc, cur) => {
	acc[cur] = true; 
	return acc; 
})
ready
New Object
values.reduce((acc, cur) => {
	return {
		...acc, 
		[cur]: true
	}
})
ready

Revisions

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