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

299
Views
mapa: ¿hay alguna forma en que podamos agregar claves a una matriz que se basa en sus valores?

Tengo el siguiente Mapa:

 '1st key' => [{'name': 'apple'}, {'other': 'orange'}], '2nd key' => [{'name': 'mango'}, {'other': 'lemon'}]

Quiero convertir este mapa en una nueva matriz y también agregar claves.

Array.from(map.values()) convierte los valores en una matriz, es de esperar, pero quiero agregar claves como atributos...

Resultado Esperado:

 [ {'id': '1st key'}, {'name': 'apple'}, {'other': 'orange'}] [ {'id': '2nd key'}, {'name': 'mango'}, {'other': 'lemon'}]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use map.entries() para obtener las claves y los valores. Luego puede insertar la clave al comienzo de la matriz de valores.

 Array.from(map.entries()).map(([key, val]) => [{id: key}, ...val]);
about 4 years ago · Juan Pablo Isaza Report
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!