Script Preparation code:
x
 
var randomArray=Array.from({length: 1000}, () => Math.floor(Math.random() * 100));
Tests:
  • Splice

     
    for (let i = randomArray.length - 1; i >= 0; --i) {
      if (randomArray[i] !=  1) {
        continue;
      }
      randomArray.splice(i, 1);
    }
    return randomArray;
  • Copy to new

     
    var newArray = [];
    for (let i = randomArray.length - 1; i >= 0; --i) {
      if (randomArray[i] ==  1) {
        continue;
      }
      newArray.push(randomArray[i]);
    }
    return newArray;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Splice
    Copy to new

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0
Firefox 104 on Windows
View result in a separate tab
Test name Executions per second
Splice 265120.0 Ops/sec
Copy to new 43305.0 Ops/sec