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

349
Visualizações
Javascript - Map 2 Child objects to parent object to switch content between each other

my problem is that I have a default layout like this:

 [
    {
      Type: C,
      Name: Category,
      Children: [
        {
          Type: C,
          Name: Category,
          Children: [
            {
              Type: F,
              ID: Field1
            },
            {
              Type: F,
              ID: Field2
            }
          ]
        }
      ]
    },
    {
      Type: C,
      Name: Category,
      Children: [
        {
          Type: F,
          ID: Field3
        }
      ]
    }
  ]

And I have a layout like this:

    [
      {
          Type: C,
          Name: Category,
          Children: [
            {
              Type: C,
              Name: Category,
              Children: [
                {
                  Type: F,
                  ID: Field2
                }
              ]
            }
          ]
        },
        {
          Type: C,
          Name: Category,
          Children: [
            {
              Type: F,
              ID: Field3
            }
          ]
        }
      ]
     }
   ]

so my removed layout is:

[
    {
      Type: C,
      Name: Category,
      Children: [
        {
          Type: C,
          Name: Category,
          Children: [
            {
              Type: F,
              ID: Field1
            }
          ]
        }
      ]
     }
   ]

Now I have a plus button next to the removed fields to add it back to the layout at the correct position and a minus button on the other side. The easiest way for me is to create unique ids at the beginning, but im not allowed to to that.

The fields can be switched in the categories, so they have to be added to the end of the category every time.

I though about weak maps, but how can I use object references to do this? How can I reference the layout objects and the removed objects to the default layout objects?

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