added this to the post as well, a place where there is an array inside an array of objects and you want all those. For example, if we want to extract all roles from the array:
[ { name: "Saransh Kataria" , roles: ['system-admin', 'developer'] }, { name: "Wisdom Geek" , roles: ['basic'] }, ].flatMap(x => x.roles);
// Output => ["admin", "system-admin", "developer"]