Array.from vs Spread (v3)

Revision 3 of this benchmark created on


Setup

window.mySet = new Set();
window.myArr = [];
for (let i = 0; i < 1000000; i++) {
	window.mySet.add(i);
	window.myArr.push(i);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.from (on Set)
const newItem = Array.from(window.mySet);
ready
Spread (on Set)
const mySet = [...window.mySet]
ready
lmao (on Set)
const mySet = Array.from([...window.mySet])
ready
Array.from (on Array)
const myArr = Array.from(window.myArr);
ready
Spread (on Array)
const myArr = [...window.myArr];
ready

Revisions

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