Run details:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36
Chrome Mobile 121
Android
Mobile
one year ago
Test name Executions per second
array.slice() 3544416.5 Ops/sec
array.splice() 4181332.2 Ops/sec
array.shift() 2014714.0 Ops/sec
Script Preparation code:
AخA
 
var array = [1, 2, 3, 4, 5, 6, 7, 8]
var itemsToRemove = 2
Tests:
  • array.slice()

     
    array = array.slice(2)
  • array.splice()

     
    array.splice(0, itemsToRemove)
  • array.shift()

     
    for (let i = 0 ; i < itemsToRemove ; i++) array.shift()