How to get distinct values from an array of objects in JavaScript? - Stack Overflow

PHOTO EMBED

Mon Apr 11 2022 22:24:33 GMT+0000 (UTC)

Saved by @arielvol

const data = [
  { group: 'A', name: 'SD' }, 
  { group: 'B', name: 'FI' }, 
  { group: 'A', name: 'MM' },
  { group: 'B', name: 'CO'}
];
const unique = [...new Set(data.map(item => item.group))]; // [ 'A', 'B']
content_copyCOPY

https://stackoverflow.com/questions/15125920/how-to-get-distinct-values-from-an-array-of-objects-in-javascript