Skip to content

Instantly share code, notes, and snippets.

@mpuz
Created March 19, 2022 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpuz/87bc2a19da61d5a1f5ca6a897dde4e7e to your computer and use it in GitHub Desktop.
Save mpuz/87bc2a19da61d5a1f5ca6a897dde4e7e to your computer and use it in GitHub Desktop.
remove dulplicates in the array of objects by one of params
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