Last active
June 3, 2020 14:36
-
-
Save bobdobbalina/a7a8e679fe61517b4f80d172f70e105b to your computer and use it in GitHub Desktop.
Javascript: Get Unique Values From An Array
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
| const array = [1, 1, 2, 3, 5, 5, 1] | |
| const uniqueArray = [...new Set(array)]; | |
| console.log(uniqueArray); // Result: [1, 2, 3, 5] | |
| // OR | |
| let uniqueArray = [...new Set([1, 2, 3, 3,3,"school","school",'ball',false,false,true,true])]; | |
| >>> [1, 2, 3, "school", "ball", false, true] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment