I am trying to get a specific field value from a nested array within an object array. I\'m assuming I\'d use map, but every time I use it in this way I get two empty arrays nest
var joe = parentArray.find(function (item) {
return item.name === 'Joe';
});
if (joe) {
var joesHobbiesNames = joe.hobbies.map(function (hobbie) {
return hobbie.name;
});
}
Or in ES6
var joe = parentArray.find((item) => item.name === 'Joe');
if (joe) {
var joesHobbiesNames = joe.hobbies.map((hobbie) => hobbie.name);
}