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

186
Views
How can I convert array to an object

I have an array with a single element that looks like this [{…}]

All I have to do simply to convert this to an object like this {}

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

0

I think the answer you are looking for is something like this:

const arr = [
  {name: 'name', value: 1},
  {name: 'name2', value: 2},
  {name: 'name3', value: 3},
  {name: 'name4', value: 4},
  {name: 'name5', value: 5},
]

const arrToObj = arr.reduce((obj, el) => {
  obj[el.name] = el.value
  return obj
}, {})

console.log(arrToObj)

about 4 years ago · Juan Pablo Isaza Report

0

Solution was array.reduce((acc, x) => ({...acc,...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!