Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get distinct values from array of arrays

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']
 
PREVIOUS NEXT
Tagged: #distinct #values #array #arrays
ADD COMMENT
Topic
Name
1+1 =