I have an array, for example:
var arr = ['ab', 'cd', 'cd', 'ef', 'cd'];
Now I want to remove duplicates that are side by side, in this example it is at indices 1 and 2 (cd).
the result should be:
var arr = ['ab', 'cd', 'ef', 'cd'];
I tried this code but it does not work:
var uniqueNames = [];
$.each(arr, function(i, el){
if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});
but this filter is unique, and I do not want this.
source
share