Skip to content

Instantly share code, notes, and snippets.

@esundahl
Created February 19, 2012 22:23
Show Gist options
  • Save esundahl/1866195 to your computer and use it in GitHub Desktop.
Save esundahl/1866195 to your computer and use it in GitHub Desktop.
Function for removing duplicate values from a javascript array
// This is a simple javascript function for removing duplicate values from an array.
function removeDupes(arr) {
var nonDupes = [];
arr.forEach(function(value) {
if (nonDupes.indexOf(value) == -1) {
nonDupes.push(value);
}
});
return nonDupes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment