const array='A,1,A,2,B,3,C,4'.split(',').filter(function(value, index, self) { return self.indexOf(value) === index; }); alert(array.join(','));