Skip to content

Instantly share code, notes, and snippets.

View khalilst's full-sized avatar

Khalil Laleh khalilst

View GitHub Profile
@khalilst
khalilst / repetitive_remover.js
Created August 21, 2020 19:24
How to remove repetitive items from an array
var x = new Array(1000000).fill(0).map(item => Math.floor(Math.random()*10));
console.time('1.Set');
var setResult = Array.from(new Set(x));
console.timeLog('1.Set');
console.log(setResult);
console.time('2.Reduce');
var reduceResult = x.reduce((acc, item) => {
if (acc.indexOf(item) === -1) {