Array = [40, 2, 40, 10, 5, 6, 10, 5, 6, 18, 15]
Sort the array to bring out homogeneous element
Array = [40, 2, 40, 10, 5, 6, 10, 5, 6, 18, 15]
Sort the array to bring out homogeneous element
You could take a Set
and filter the values who are alreday seen.
var array = [40, 2, 40, 10, 5, 6, 10, 5, 6, 18, 15],
seen = array.filter((s => v => s.has(v) || !s.add(v))(new Set));
console.log(seen);