Skip to content

Instantly share code, notes, and snippets.

@MaxXxiMast
Created May 30, 2017 15:49
Show Gist options
  • Save MaxXxiMast/f98ec5afeaecaf724ae345268924d539 to your computer and use it in GitHub Desktop.
Save MaxXxiMast/f98ec5afeaecaf724ae345268924d539 to your computer and use it in GitHub Desktop.
Function to remove duplicate elements from an array
function removeDuplicates(values) {
var uniqueValues = {};
values.forEach(function(i) {
if (!uniqueValues[i]) {
uniqueValues[i] = true;
}
});
return Object.keys(uniqueValues);
}
// var values = ['a','b','a','a','b','c','b'] will return ['a', 'b', 'c']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment