Skip to content

Instantly share code, notes, and snippets.

@sharjeel619
Created September 30, 2020 20:39
Show Gist options
  • Save sharjeel619/ca02fa307ac7212c5038a80e8ad94c09 to your computer and use it in GitHub Desktop.
Save sharjeel619/ca02fa307ac7212c5038a80e8ad94c09 to your computer and use it in GitHub Desktop.
//https://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript?page=2&tab=oldest#tab-top
const things = [
{place:"here",name:"stuff"},
{place:"there",name:"morestuff"},
{place:"there",name:"morestuff"}
];
const filtered = things.filter(function({place, name}) {
const key =`${place}${name}`;
return !this.has(key) && this.add(key);
}, new Set);
console.log(filtered);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment