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

104
Views
How to data to Array using vanilla Javascript

I need object to convert to array and push to array. Depending on what is chosen, I get it like this ->

{
 firstUnit: {label: 'caca', value: 70}
 secondUnit: {label: 'Parent 2', value: 9}
} 

Or sometimes i got only

{
 firstUnit: {label: 'caca', value: 70} 
} 

or

{ 
 secondUnit: {label: 'Parent 2', value: 9}
} 

What I need ?

I need to convert this

{
 firstUnit: {label: 'caca', value: 70}
 secondUnit: {label: 'Parent 2', value: 9}
}  

or

{
 firstUnit: {label: 'caca', value: 70} 
} 

TO

 [ {label: 'caca', value: 70} , {label: 'Parent 2', value: 9}]

or if only one object

 [{label: 'caca', value: 70}]

What I am try ?

let formVal = [formValues];
let newVal = [formVal?.map((values) => values)]

This is no work property.

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

0

Object.values will work here.

The Object.values() method returns an array of a given object's own enumerable property values

const data = {
 firstUnit: { label: 'caca', value: 70 },
 secondUnit: { label: 'Parent 2', value: 9 }
};

const out = Object.values(data);

console.log(out);

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!