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

215
Views
Objeto JavaScript dentro de la fusión de matriz múltiple

Tengo un objeto dentro de la lista de objetos de valores de matriz, quiero fusionar el valor del objeto Gracias por la ayuda

 const List = { school1: [{studentname:'1'},{studentname:'2'}] school2: [{studentname:'21'},{studentname:'22'}] school3: [{studentname:'31'},{studentname:'32'}] } Trying Get like this const List = [{studentname:'1'},{studentname:'2'},{studentname:'21'},{studentname:'22'},{studentname:'31'},{studentname:'32'}]
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede usar Object.values() y Array.flat() para obtener el resultado deseado:

 const List = { school1: [{studentname:'1'},{studentname:'2'}], school2: [{studentname:'21'},{studentname:'22'}], school3: [{studentname:'31'},{studentname:'32'}] } const result = Object.values(List).flat(); console.log('Result:', result)
 .as-console-wrapper { max-height: 100% !important; }

about 4 years ago · Juan Pablo Isaza Report

0

 var a = { a1: [{name:'s1'}, {name: 's2'}], a2: [{name:'s3'}, {name: 's4'}], a3: [{name:'s5'}, {name: 's6'}], } var list = []; Object.keys(a).forEach(x => {list = [...list, ...a[x]]}) console.log(list)

about 4 years ago · Juan Pablo Isaza Report

0

Solución de fuerza bruta:

 const List = { school1: [{studentname:'1'},{studentname:'2'}], school2: [{studentname:'21'},{studentname:'22'}], school3: [{studentname:'31'},{studentname:'32'}] } let List2 = []; for(let i of Object.values(List)){ List2.push(i) } console.log(List2)

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!