Map values to array

Benchmark created on


Setup

const entries = []
for(let i = 0; i < 3000; i++) {
	const id = crypto.randomUUID().split('-')[0]
	entries.push([id, {id, children: [], name: ''}])
}
const data = new Map(entries)

Test runner

Ready to run.

Testing in
TestOps/sec
Using for...of
const result = [] 
for(item of data) {
	result.push(item[1])
}

ready
Using forEach
const result = []
data.forEach(item => {
	result.push(item)	
})

ready
Array.from
const result = Array.from(data.values())

ready
spread
const result = [...data.values()]

ready

Revisions

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