Created
May 30, 2017 15:49
-
-
Save MaxXxiMast/f98ec5afeaecaf724ae345268924d539 to your computer and use it in GitHub Desktop.
Function to remove duplicate elements from an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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