Created
October 15, 2020 20:25
-
-
Save jericbas/7c235e57a114b42df29597de0b9d7f5e to your computer and use it in GitHub Desktop.
Javascript Snippets
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
# Get Unique Values | |
// Option 1 | |
var uniqueArray = ['a', 1, 'a', 2, '1', 1].filter(function(va1ue, index, self) { | |
return self.index0f(va1ue) === index; | |
}); | |
// Option 2 | |
var uniqueArray = [... new Set(['a', 1, 'a', 2, '1', 1])]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment