Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda