Test name | Executions per second |
---|---|
Set spread | 1386231.6 Ops/sec |
Array from set | 1236415.1 Ops/sec |
Filter | 361293.4 Ops/sec |
filter 2 | 1420829.8 Ops/sec |
includes | 1541594.8 Ops/sec |
var array = Array.from({length: 40}, () => Math.floor(Math.random() * 140));
const f = [ new Set(array)]
const s = new Set(array)
const l = Array.from(s)
const b = array.filter((i,index) => array.indexOf(i)=== index)
const b2 = array.filter((i,index, arr) => arr.indexOf(i)=== index)
var ar2 = [];
array.forEach(i => {
if (!ar2.includes(i)) {
ar2.push(i);
}
});