Created
March 19, 2022 13:45
-
-
Save mpuz/87bc2a19da61d5a1f5ca6a897dde4e7e to your computer and use it in GitHub Desktop.
remove dulplicates in the array of objects by one of params
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 filteredArr = arr.reduce((acc, current) => { | |
const x = acc.find(item => item.id === current.id); | |
if (!x) { | |
return acc.concat([current]); | |
} else { | |
return acc; | |
} | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment