I have an object array like the following. Each object in the array has an instructors field which is also an array. How can I get all email fields from this object array via lodash?
Do I need to use a double _.map function? I can run a foreach in the object and then another foreach in the instructors but I don't think that's very elegant. I can't wrap my head around getting values from object arrays that contain other array fields. Any help would be greatly appreciated.
[
{
'title': 'New Class',
'instructors': [
{
'email': '[email protected]'
},
{
'email': '[email protected]'
}
]
},
{
'title': 'New Class 2',
'instructors': [
{
'email': '[email protected]'
},
{
'email': '[email protected]'
}
]
}
];