Run details:
Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36
Chrome Mobile 106
Android
Mobile
2 years ago
Test name Executions per second
none 16627.1 Ops/sec
new 16091.1 Ops/sec
length 16935.1 Ops/sec
Tests:
  • none

    x
     
    const n = 100;
    function getRandomInt(max) {
        return Math.floor(Math.random() * max);
    }
    const arr = [];
    for(let i = 0; i < n; ++i) {
      arr.push(getRandomInt(1000))
    }
  • new

     
    const n = 100;
    function getRandomInt(max) {
        return Math.floor(Math.random() * max);
    }
    const arrPre = new Array(n);
    for(let i = 0; i < n; ++i) {
      arrPre[i] = getRandomInt(1000)
    }
  • length

     
    const n = 100;
    function getRandomInt(max) {
        return Math.floor(Math.random() * max);
    }
    const arrLen = []; arrLen.length = n;
    for(let i = 0; i < n; ++i) {
      arrLen[i] = getRandomInt(1000)
    }