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

133
Views
¿Cómo puedo convertir una matriz en un objeto de matriz en reaccionar?

tengo datos en array

 ["Avengers","Batman","Spiderman","IronMan"]

cómo puedo encubrir a continuación

 {"Avenger":"Avenger","Batmane":"Batman","Spiderman":"Spiderman","Ironman":"Ironman"}
about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

Puedes hacerlo así:

 let arr = ["Avengers","Batman","Spiderman","IronMan"]; let obj = arr.reduce((acc, item)=> ({...acc, [item]: item}) , {}); console.log(obj);

about 4 years ago · Santiago Gelvez Report

0

Alguien más mencionó reducir, pero no recomiendo copiar objetos en cada iteración.

Aquí hay un enfoque más eficaz.

 const arr = ["Avengers","Batman","Spiderman","IronMan"]; const obj = {}; for (const el of arr) { obj[el] = el; } console.log(obj);

about 4 years ago · Santiago Gelvez Report

0

Puede usar reducir para convertir una matriz en un objeto. Puedes ver algunos ejemplos aquí Convert Array to Object

about 4 years ago · Santiago Gelvez 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!