array creation

Benchmark created on


Setup

const n = 100

Test runner

Ready to run.

Testing in
TestOps/sec
es6 .fill()
Array(n)
  .fill(0)
  .map((_, i) => i)
ready
loop
const a = [];

for (let i=0; i<=n; i++) {
  a[i] = i
}
ready
while
const a = []; 
let i = 0;

while (a.length <= n) {
  a[i] = i++
}
ready
es6 .apply()
Array
  .apply(null, Array(n))
  .map((_, i) => i);
ready

Revisions

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