I attempted to extract the father's name from an array of objects and populate a new array with these names. Here is an example:
var people = [
{
name: "Mike Smith",
family: {
father: "Harry Smith",
}
},
{
name: "Tom Jones",
family: {
father: "Richard Jones",
}
}
];
var fathers = [];
for (var {family: { father: f } } of people) {
console.log("Father: " + f);
father.push(f);
}
Is there a non-loop solution in es6 to populate the fathers
array from people
?