array creation (v6)

Revision 6 of this benchmark created on


Setup

const n = 10

Teardown


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.