Created
September 30, 2020 20:39
-
-
Save sharjeel619/ca02fa307ac7212c5038a80e8ad94c09 to your computer and use it in GitHub Desktop.
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
//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