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

176
Views
What is the cleanest way to convert this object into an array of key-pair objects?

I have an object below, that I need in the following format. I can't seem to get the named pairs working. Happily to accept lodash answers as well. Thanks

const object = {
  "mobile": "04000000",
  "address": "123 fake st"
}

That I need to turn into this format.

const format = [
  {
    name: "mobile",
    value: "04000000"
  },
  {
    name: "address",
    value: "123 fake st"
  }
]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use Object.entries to get the key/value pairs of the object as an array, and Array.map to construct the object for each item:

const object = {
    "mobile": "04000000",
    "address": "123 fake st"
}


const res = Object.entries(object).map(e => ({name: e[0], value: e[1]}))

console.log(res)

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!