const arrOfObjs = [
{
name: 'someName',
tags: [
'sci-fi',
'strategy',
'sandbox',
]
},
{
name: 'someOtherName',
tags: [
'sci-fi',
'mining',
'woodcutting',
'sandbox'
]
}
];
let uniqueTags = [...new Set(arrOfObj.map(obj => obj.tags).flat(1))];
// ['sci-fi', 'strategy', 'sandbox', 'mining', 'woodcutting']
var myArray = ['a', 1, 'a', 2, '1'];
let unique = [...new Set(myArray)];
console.log(unique); // unique is ['a', 1, 2, '1']
const categories = ['General', 'Exotic', 'Extreme', 'Extreme', 'General' ,'Water', 'Extreme']
.filter((value, index, categoryArray) => categoryArray.indexOf(value) === index);
This will return an array that has the unique category names
['General', 'Exotic', 'Extreme', 'Water']