Skip to content

Instantly share code, notes, and snippets.

@jaygraygray
Created July 20, 2017 23:02
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 jaygraygray/a633ddaaccdd3f2f38366b128a9086c9 to your computer and use it in GitHub Desktop.
Save jaygraygray/a633ddaaccdd3f2f38366b128a9086c9 to your computer and use it in GitHub Desktop.
function getUniqueProps(arrayOfObjects, propToCheck) {
let newObj = new Set();
arrayOfObjects.forEach(item => {
newObj.add(JSON.stringify(item[propToCheck]))
})
let result = Array.from(newObj).map(item => {
return { [propToCheck]: JSON.parse(item) }
})
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment