Ive got an array of objects. Inside each object there is another array. I want to extract distinct values from these arrays.
var data = [
{categorie: 'Stuff', type: 'One', designs: ['A', 'B']},
{categorie: 'Stuff', type: 'Two', designs: ['C']},
{categorie: 'Stuff', type: 'One', designs: ['D']},
{categorie: 'Other', type: 'Three', designs: ['C', 'D']}
];
console.log([...new Set(data.map(x => x.categorie))]);
console.log([...new Set(data.map(x => x.type))]);
//expected output for designs ['A','B','C','D']
console.log([...new Set(data.flatMap(x => x.designs))]);?x.categorie/x.type?