Range

Benchmark created on


Setup

const ls = [];

for (let l = 0; l < 1000; l++) {
	ls.push(l);
} 

Test runner

Ready to run.

Testing in
TestOps/sec
Array.from
for (const l of ls) {
	Array.from({length: l}, (x, i) => i);
}
ready
Keys
for (const l of ls) {
	[...new Array(l).keys()];
}
ready
Fill + Map
for (const l of ls) {
	new Array(l)
		.fill(0)
		.map((_, index) => index)
}
ready

Revisions

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