Create Array JavaScript

JavaScript performance comparison

Test case created by completejavascript

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Array Literal
const arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
pending…
Array Literal + Loop + push()
const arr2 = [];
for (let i = 0; i < 10; i++) { arr2.push(0); }
pending…
Array.from() + constructor
const arr3 = Array.from(new Array(10), () => 0);
pending…
Array.from() + Object length
const arr4 = Array.from({ length: 10 }, () => 0);
pending…
Eval + repeat + slice
const arr5 = eval('['+",0".repeat(10).slice(1)+']')
pending…
Array Constructor + fill()
const arr6 = new Array(10).fill(0);
pending…
Spread + Array.keys
const arr7 = [...new Array(10).keys()]
pending…

Compare results of other browsers

Revisions

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

0 Comments