array creation (v5)

Revision 5 of this benchmark created on


Setup

const n = 100
let a, i = undefined;

Teardown

a = undefined
i = undefined

Test runner

Ready to run.

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

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

while (a.length <= n) {
  a[i] = i++
}
ready
es6 .apply()
var a = Array
  .apply(null, Array(n))
  .map((_, i) => i);
ready
destructure
var a = [...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.