Created
March 19, 2022 13:45
remove dulplicates in the array of objects by one of params
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 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