Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!