Skip to content

Instantly share code, notes, and snippets.

@mystix
Last active May 19, 2018 08:02
Show Gist options
  • Save mystix/6724673 to your computer and use it in GitHub Desktop.
Save mystix/6724673 to your computer and use it in GitHub Desktop.
[JavaScript] Remove duplicate occurences of string within string
// adapted from http://stackoverflow.com/a/13486540
function dedupe(str, delimiter) {
return str.split(delimiter || ',').reverse().filter(function(e, i, arr) {
return arr.indexOf(e, i+1) === -1;
}).reverse();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment