Created
July 21, 2021 22:47
-
-
Save nhuxhr/2eb929cb36b1001c99a4ac1ab7b5f7ce to your computer and use it in GitHub Desktop.
Remove duplicates from an Array in JavaScript
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
/** | |
* Remove duplicates from an Array in JavaScript | |
* @author JSX Clan <jsxclan.dev@gmail.com> | |
*/ | |
const array = [0, 1, 0, 'foo', 'bar', 'bar', true, true, false]; | |
const filteredArray = [...new Set(array)]; | |
console.log(filteredArray); | |
// Output: [0, 1, "foo", "bar", true, false] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment