There is an array
var array = ['one', 'two', 'three', 'one', 'two', 'one', 'three', 'one'];
and you need to remove duplicate values, if any, so that in this example it would turn out
var array = ['one','two','three'];
I tried it this way, but every second one is deleted.
for (var i=0; i<array.length; i++){ var compare = array[i]; for (var j=0; j<array.length; j++){ if (compare == array[j]){ delete data_search[j]; } } }
function uniq(a) { return Array.from(new Set(a)); }
function uniq(a) { return Array.from(new Set(a)); }
- Alexey Shimansky