Created
January 18, 2019 16:52
-
-
Save CristalT/7793205d2c367d4fcd214514827cf9c8 to your computer and use it in GitHub Desktop.
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
// Two ways to remove array duplicates | |
const array = [1, 2, 3, 4, 4, 4, 5] | |
// Way 1 | |
let uniq = array.filter((el, index) => array.indexOf(el) === index) | |
console.log(uniq) | |
// Way 2 | |
uniq = [...new Set(array)] | |
console.log(uniq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment