Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134
Linux
Desktop
one month ago
Test name Executions per second
array.slice() 7391687.5 Ops/sec
array.splice() 37893508.0 Ops/sec
array.shift() 26723.3 Ops/sec
Script Preparation code:
AخA
 
var array = Array(10000).fill(0)
var itemsToRemove = 5000 
Tests:
  • array.slice()

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

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

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