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

195
Views
¿Cuál es la forma más limpia de convertir un objeto en una lista sin usar un bucle for doble?

Tengo un objeto llamado 'tiempos', que contiene otro objeto llamado '20102', que contiene una lista de 3 objetos. Se parece a esto:

 times: { 20102: [ { name:'jane', age:12 }, { name:'josh', age:19 }, { name:'jill', age:14 }, ] }

Sin embargo, lo que quiero que se vea así es:

 times:[ { name:'jane', age:12 }, { name:'josh', age:19 }, { name:'jill', age:14}, ]

Estaba pensando en hacer un doble for loop pero eso no es eficiente. ¿Cuál es una mejor manera?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

usando Object.values() y flat()

 var x = { times: { 20102: [{ 'key': '1' }, { 'key': '2' }, { 'key': '3' }, ] } }; x.times = Object.values(x.times).flat(); console.log(x);

Si sabes que solo habrá una llave

 var x = { times: { 20102: [{ 'key': '1' }, { 'key': '2' }, { 'key': '3' }, ] } }; x.times = Object.values(x.times)[0]; console.log(x);

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!