Slice vs splice
Date tested:
one year ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/113.0
Test name
Executions per second
Splice
36081916.0 Ops/sec
Slice
10102203.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var arrayOne = [1, 3, 5, 11, 13]; var index = arrayOne.indexOf(5);
Tests:
Splice
arrayOne.splice(index, 1);
Slice
[...arrayOne.slice(0, index), ...arrayOne.slice(index+1) ]
Open this result on MeasureThat.net