remove duplicate characters in a string javascript

Posted by Paidboom - 2 months ago

how to remove duplicate characters from string in javascript?

function removeDuplicateCharacters(string) {
  return string
    .split('')
    .filter(function(item, pos, self) {
      return self.indexOf(item) == pos;
    })
    .join('');
}
console.log(removeDuplicateCharacters('baraban'));