I was trying to create a array from an array of objects. I wanted to get the name of father from each object. For 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 anyway to do pouplate the fathers
array from people
without the loop in es6?