Run details:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36
Chrome Mobile 115
Android
Mobile
one year ago
Test name Executions per second
Set spread 149703.7 Ops/sec
Array from set 143385.8 Ops/sec
Filter 220887.8 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((element,index, self) => self.indexOf(element)=== index)