Created
July 16, 2020 19:13
-
-
Save thisaurel/ae7bd5d08384f1162a0abaa0541e16e3 to your computer and use it in GitHub Desktop.
This file contains 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
Set is a new data object introduced in ES6. Because Set only lets you store unique values. | |
When you pass in an array, it will remove any duplicate values. | |
const myArray = [0, 1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7]; | |
const removeDuplicatesFromArray = Array.from(new Set(myArray)); | |
console.log(removeDuplicatesFromArray); | |
Result: (8) [0,1,2,3,4,5,6,7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment