Skip to content

Instantly share code, notes, and snippets.

@EdwardGoomba
Created September 16, 2020 03:24
Show Gist options
  • Save EdwardGoomba/0f4a44336b55c60951eb9504aaa27008 to your computer and use it in GitHub Desktop.
Save EdwardGoomba/0f4a44336b55c60951eb9504aaa27008 to your computer and use it in GitHub Desktop.
Remove Duplicate Object from Array
function removeDuplicateObjectFromArray(array, key) {
return array.filter((obj, index, self) =>
index === self.findIndex((el) => (
el[key] === obj[key]
))
)
}
const data = arr.reduce((filter, current) => {
const dk = filter.find(item => item.value === current.value);
if (!dk) {
return filter.concat([current]);
} else {
return filter;
}
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment