Created
March 29, 2022 20:40
-
-
Save cuneydbolukoglu/89fee2d95e8e5a7814ee700fdfce7cbe to your computer and use it in GitHub Desktop.
How to Remove Array Duplicates in ES6
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
const data = [1, 2, 2, 3, 3, 4]; | |
const removeArrayDuplicates = data.reduce( | |
(unique, item) => (unique.includes(item) ? unique : [...unique, item]), | |
[] | |
); | |
console.log(removeArrayDuplicates); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment