Skip to content

Instantly share code, notes, and snippets.

@chrisjhoughton
Last active December 17, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisjhoughton/5591798 to your computer and use it in GitHub Desktop.
Save chrisjhoughton/5591798 to your computer and use it in GitHub Desktop.
A function for getting all the unique values in an array.
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