Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Last active January 31, 2017 09:57
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 karlpokus/dc6135b54abb53b06fcd to your computer and use it in GitHub Desktop.
Save karlpokus/dc6135b54abb53b06fcd to your computer and use it in GitHub Desktop.
Unique items in array. Return count or items.
// data is an array
function unique(data) {
return data.reduce(function(base, item){
if (base.indexOf(item) < 0 ) {
base.push(item);
}
return base
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment