Set to array

Benchmark created on


Setup

const set = new Set();
for (let i = 0; i < 100000; i++) {
	set.add(Math.random().toString(36));
}

Test runner

Ready to run.

Testing in
TestOps/sec
Spread
const result = [...set.keys()]
ready
Array.from
const result = Array.from(set);
ready
For of
const result = [];
for (const item of set) {
	result.push(item);
}
ready
For each
const result = [];
set.forEach((item) => result.push(item));
ready

Revisions

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