-4

I have an array which has many objects, I want to make an array of tag values so I can display the non repeated tags in the frontend. This is the array, and from which I want to create the new array which will include all the tag values.

enter image description here

Can you please share with me a solution or maybe a way to solve this ? Thanks

flyingfox
  • 13,414
  • 3
  • 24
  • 39

1 Answers1

2

You can use Array#map to get all the tag property values, and then create a Set from that to get the unique ones.

const tags = [...new Set(yourObj.nodes.map(x => x.tag))];
Unmitigated
  • 76,500
  • 11
  • 62
  • 80