Spread vs Array.from vs push (v2)

Revision 2 of this benchmark created on


Setup

function* getValues() {
	for (let i = 0; i < 1_000; i++) {
		yield Math.random();
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Spread
const vals = [...getValues()];
ready
Array.from
const vals = Array.from(getValues());
ready
For/of with push
const vals = [];
for (const v of getValues()) vals.push(v);
ready

Revisions

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