Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0 bb-mozilla-auto-config host:a584
Firefox 68
Linux
Desktop
3 years ago
Test name Executions per second
Set spread 369908.2 Ops/sec
Array from set 342615.9 Ops/sec
Filter 691882.9 Ops/sec
Script Preparation code:
AخA
 
var array = Array.from({length: 40}, () => Math.floor(Math.random() * 140));
Tests:
  • Set spread

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

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

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