Test name | Executions per second |
---|---|
array.slice() | 3544416.5 Ops/sec |
array.splice() | 4181332.2 Ops/sec |
array.shift() | 2014714.0 Ops/sec |
var array = [1, 2, 3, 4, 5, 6, 7, 8]
var itemsToRemove = 2
array = array.slice(2)
array.splice(0, itemsToRemove)
for (let i = 0 ; i < itemsToRemove ; i++) array.shift()