I have:
[{
"id": 1,
"listForExtract": [{
"value1": "1A",
"value2": "2A"
}, {
"value1": "1B",
"value2": "2B"
}, ]
},
{
"id": 2,
"listForExtract": [{
"value1": "1C",
"value2": "2C"
}, {
"value1": "1D",
"value2": "2D"
}, ]
}]
I want to extract the objects inside listForExtract to a new array like using some function of underscore passing the ID:
something like: _.extractNestedArrayFrom(myArray, 'listForExtract', {'id':2})
[{
"value1": "1A",
"value2": "2A"
}, {
"value1": "1B",
"value2": "2B"
}]