Last active
December 17, 2015 09:59
-
-
Save chrisjhoughton/5591798 to your computer and use it in GitHub Desktop.
A function for getting all the unique values in 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
var unique = function(array) { | |
var u = {}, a = []; | |
for (var i = 0, l = array.length; i < l; ++i) { | |
if (u.hasOwnProperty(array[i])) { | |
continue; | |
} | |
a.push(array[i]); | |
u[array[i]] = 1; | |
} | |
return a; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment