Skip to content

Instantly share code, notes, and snippets.

@davidbanham
Created August 11, 2011 06:54
Show Gist options
  • Save davidbanham/1139047 to your computer and use it in GitHub Desktop.
Save davidbanham/1139047 to your computer and use it in GitHub Desktop.
Reduce array to unique elements
var array = [0, 1, 2, 1, 3];
var uniques = [];
for ( var i in array ) {
uniques[array[i]] = array[i];
};
console.log(uniques);
// Returns [ 0, 1, 2, 3 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment