Destructure

Benchmark created on


Setup

const array = Array.from({length: 20080}).fill(0).map((_, index) => index)
const output = {}

Test runner

Ready to run.

Testing in
TestOps/sec
Destructure
array.reduce((acc, val) => ({...acc, [val]: 1}), {})
ready
Modify
array.reduce((acc, val) => {
	acc[val] = 1;
	return acc;
}, {})
ready
for
for (const val of array) {
	output[val] = 1;
}
ready
for i
for (let i = 0; i < array.length; i++) {
	output[array[i]] = 1;
}
ready

Revisions

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