Script Preparation code:
AخA
 
var data1 = [];
for(i=0; i<10000; i++){data1.push(i);}
var data2 = [];
for(i=0; i<10000; i++){data2.push(i);}
Tests:
  • Unshift with find

    x
     
        const rest = data1.filter(item => item !== 600);
        rest.unshift(data1.find(item => item.type == 600));
        return rest;
      
  • Slice with findIndex

     
        const cautelarPosition = data2.findIndex(item => item.type == 500);
        data2.splice(0, 0, data2.splice(cautelarPosition, 1)[0]);
        return data2;
      
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Unshift with find
    Slice with findIndex

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0
Firefox 95 on Ubuntu
View result in a separate tab
Test name Executions per second
Unshift with find 2043.7 Ops/sec
Slice with findIndex 8693.4 Ops/sec