Skip to content

Instantly share code, notes, and snippets.

@fijiwebdesign
Created February 20, 2017 16:38
Show Gist options
  • Save fijiwebdesign/e0037950fada8f5d4e9f6a1c8637b2cc to your computer and use it in GitHub Desktop.
Save fijiwebdesign/e0037950fada8f5d4e9f6a1c8637b2cc to your computer and use it in GitHub Desktop.
Unique array in Javascript
// ES5
function arrUnique(arr) {
return arr.filter( function(value, index) {
return arr.indexOf(value) == index
})
}
// ES6
const arrUnique = arr =>
arr.filter( (value, index) => arr.indexOf(value) == index )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment