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

98
Visualizações
create dinamically nested object inside double loop forEach

I'm attempting to create a nested object with the same name but different value in this way : example..

const myTestfunction =():void=> {

    const licenses = {};

    valsLicenses.forEach((valLicense) => {
       let license:any = {};
       valLicense.forEach((elem, i, arr) => {
          
          license["licenseId"] = arr[0];
          license["expireDate"] = arr[1];
          license["os"] = arr[2];
          Object.assign(licenses, license);
        });
      });
};

result of this is : enter image description here

and i'd want a JSON object something like this {license:{...},license:{...},license:{...}}

Nevertheless, when I check the object, only the last three value are stored inside the object, i think that this happens because when the object is initialized, the object's address does not change, but I do not spot a solution to add a newly initialized object with the same name inside the same object...how could I resolve it?

about 4 years ago · Juan Pablo Isaza
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