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

244
Visualizações
Remove surrounding array from array of object

does anyone know how I can remove a surrounding array from an array of objects? In my case, I only have one object in this array. [{"id":"6","email":"test@test.com"}] Also, would the solution work in the case of multiple objects in the array? Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have an array of objects. That's great, because it's the easiest way to store and manipulate lists of records.

You can use array methods like .map that allow you to treat each record separately, telling it what to do individually with each element. That's also great, because it basically "removes the element from the array" while still processing the whole array, which is what I think you're after.

Simple example to create a dropdown:

const data = [{"id":"6","email":"test@test.com"}, {"id":"12","email":"test2@test.com"}];
const drawEmailDropdown = () => {
  let options = data.map(d => `<option value='${d.id}'>${d.email}</option>`);
  return `<select>` + options.join("") + `</select>`;
};

document.querySelector("#container").innerHTML = drawEmailDropdown();
<div id="container"></div>

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