Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Chrome 132
Mac OS X 10.15.7
Desktop
2 months ago
Test name Executions per second
Sets 344491.9 Ops/sec
Arrays 697001.1 Ops/sec
Script Preparation code:
AخA
 
const array1 = Array.from({length: 100}, () => Math.floor(Math.random() * 140));
const array2 = Array.from({length: 100}, () => Math.floor(Math.random() * 140));
Tests:
  • Sets

     
    const set1 = new Set(array1);
    const set2 = new Set(array2);
    set1.difference(set2);
  • Arrays

     
    array1.filter((id) => !array2.includes(id));