Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
Remove subarray of array and convert into objects?

I have an array of arrays which I have to convert into an array of objects:

[
  [
    {
      lable: "text",
      anotherValue: "anothervalue"
    }
  ], 
  [
    {
      lable: "text",
      anotherValue: "anothervalue"
    }
  ]
]

I need to convert this into:

[
  {
    lable: "text",
    anotherValue: "another value"
  }, 
  {
    lable: "text",
    anotherValue: "another value"
  }
]
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can do that using map. The function given to map as a parameter unpacks each subarray and replaces it by the object within.

a = [
  [{lable:'text',anotherValue:'anothervalue'}], 
  [{lable:'text',anotherValue:'anothervalue'}]
];

result = a.map((o) => o[0])
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda