Remove duplicate values from JS array [duplicate]
TL;DR Using the Set constructor and the spread syntax: uniq = […new Set(array)]; “Smart” but naïve way uniqueArray = a.filter(function(item, pos) { return a.indexOf(item) == pos; }) Basically, we iterate over the array and, for each element, check if the first position of this element in the array is equal to the current position. Obviously, … Read more