Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Chrome 107
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
Set spread 566592.5 Ops/sec
Array from set 610246.3 Ops/sec
Filter 1813161.0 Ops/sec
Script Preparation code:
AخA
 
var array = Array.from({length: 20}, () => Math.floor(Math.random() * 140));
Tests:
  • Set spread

     
    const f = [... new Set(array)]
  • Array from set

    x
     
    const l = Array.from(new Set(array))
  • Filter

     
    const b = array.filter((i,index,a) => a.indexOf(i) === index)