Script Preparation code:
AخA
 
var array = [];
for (let i = 0; i < 100000; i++) {
   array.push(Math.floor((Math.random() * 10) + 1));
}
Tests:
  • Using indexOf

     
    array.filter((item, index) => array.indexOf(item) != index);
  • Using lastIndexOf

     
    array.filter((item, index) => array.lastIndexOf(item) != index);
  • Using a Set

     
    [...new Set(array)]
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Using indexOf
    Using lastIndexOf
    Using a Set

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 23 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Using indexOf 251.7 Ops/sec
Using lastIndexOf 139.1 Ops/sec
Using a Set 741.3 Ops/sec