Created
February 20, 2017 16:38
-
-
Save fijiwebdesign/e0037950fada8f5d4e9f6a1c8637b2cc to your computer and use it in GitHub Desktop.
Unique array in Javascript
This file contains hidden or 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
// 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