Created
February 19, 2012 22:23
-
-
Save esundahl/1866195 to your computer and use it in GitHub Desktop.
Function for removing duplicate values from a javascript array
This file contains hidden or 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
// 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