Segue o meu codigo para o espalhamento do objeto cliente eusando uma array de objetos e for in:
const clients = [
{
name: "Josias Silva",
cpf: "44455577789",
email: "josias98@email.com",
dependent: [
{ nome: "Maria Silva", parentage: "wife", birth: "03/05/1970" },
{ nome: "Anna Silva", parentage: "daughter", birth: "18/01/2001" },
{ nome: "Albert Silva", parentage: "son", birth: "21/09/2009" }
]
},
{
name: "Antonio Barbosa",
cpf: "44455577789",
email: "josias98@email.com",
dependent: [
{ nome: "Franciele Barbosa", parentage: "wife", birth: "03/05/1970" },
{ nome: "Beth Barbosa", parentage: "daughter", birth: "18/01/2001" },
{ nome: "Aline Barbosa", parentage: "daughter", birth: "21/09/2009" }
]
},
{
name: "Lucas Souza",
cpf: "44455577789",
email: "josias98@email.com",
dependent: [
{ nome: "Elena Souza", parentage: "wife", birth: "03/05/1970" },
{ nome: "Sofia Souza", parentage: "daughter", birth: "18/01/2001" },
{ nome: "Eduardo Souza", parentage: "son", birth: "21/09/2009" }
]
},
{
name: "Isabel Dias",
cpf: "44455577789",
email: "josias98@email.com",
dependent: [
{ nome: "Armando Dias", parentage: "husband", birth: "03/05/1970" },
{ nome: "Johnathan Dias", parentage: "son", birth: "18/01/2001" },
{ nome: "Francisco Dias", parentage: "son", birth: "21/09/2009" }
]
}
];
const dependents = [];
for (const obj in clients) {
dependents.push(...clients[obj].dependent)
}
console.table(dependents);