香港专业教育学院有一系列的对象。每个对象内都有另一个数组。我想从这些数组中提取不同的值。
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']Run Code Online (Sandbox Code Playgroud)
javascript ×1