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

114
Views
convert a key value object to a single array

I need to convert a object

{score: 77, id: 166}

to an array,

[77,166]

I tried,

Object.keys(obj).map((key) => [obj[key]]);

but seems like, it returns as 2 arrays.

[[77][166]]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You just had an extra pair of square brackets in your code

const obj = {score: 77, id: 166};
const result = Object.keys(obj).map((key) => obj[key]);

console.log(result)

about 4 years ago · Juan Pablo Isaza Report

0

You can use also use Object.values(obj) to achieve this result

const obj = {
  score: 77,
  id: 166
}
const result = Object.values(obj)

console.log(result);

this will return you an array of values

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!