HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var arr1 = [];
for(let i = 0; i < 100000; i++) {
  arr1.push({"index": i});
}
var arr2 = [];
for(let i = 49000; i >= 0; i--) {
  arr2.push(arr1[i*2]);
}
Tests:
  • Lodash

     
    const notInArr = _.difference(arr2, arr1)
  • Set & Filter

     
    const arr2Set = new Set(arr2);
    const notInArr2 = arr1.filter(value => !arr2Set.has(value));
  • map

     
    const arr2Map = new Map(arr2.map((e2) => ([e2.index, e2])));
    const notInArr2 = arr1.filter(value => !arr2Map.has(value));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash
    Set & Filter
    map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Chrome 131 on Windows
View result in a separate tab
Test name Executions per second
Lodash 147.5 Ops/sec
Set & Filter 222.3 Ops/sec
map 153.0 Ops/sec