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

125
Views
i have data in the form of object of object in javascript

Hi everyone I have object of object and I just want to combine data inside inner object in the form of array is there any way to that

input data

  let data = {
      
      ok123b:{
        name:'shanu'
    },
       of123b:{
        name:'rahul'
    },
       og1453jdfk:{
        name:'ak'
    },
       ok1kjjdde23b:{
        name:'man'
    }
      
      
    }
    
    let arrayOfData  =[data.ok123b.name,data.of123b.name,data.og1453jdfk.name,data.ok1kjjdde23b.name]
    console.log(arrayOfData);
    
    //this is hard coded i want dynamic code to convert data in the form of array

expected output

output  = ['shanu','rahul','ak','man'];
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

There are several ways you can achieve this. I have updated my answer to include these.

Solution 1 (For loop and push() method)

You can use a simple for loop and push (add) each object's name to the array.

let data = {
  ok123b:{name: 'shanu'}, 
  of123b:{name: 'rahul'}, 
  og1453jdfk:{name:'ak'}, 
  ok1kjjdde23b:{name: 'man'}
}
let arrayOfData = [];
for(item in data) {
  arrayOfData.push(data[item]['name'])
}
console.log(arrayOfData);

Solution 2 (Using Object.values() and map() method)

let data = {
  ok123b:{name: 'shanu'}, 
  of123b:{name: 'rahul'}, 
  og1453jdfk:{name:'ak'}, 
  ok1kjjdde23b:{name: 'man'}
}
let r = Object.values(data);
let result = r.map((element) => element.name)
console.log(result);

Solution 3 (One liner using Object.entries() and map() method)

let data = {
  ok123b:{name: 'shanu'}, 
  of123b:{name: 'rahul'}, 
  og1453jdfk:{name:'ak'}, 
  ok1kjjdde23b:{name: 'man'}
}
let result = Object.entries(data).map(a=>a[1].name)
console.log(result);

However as @Chris G mentioned, this is a very common question so you should probably browse similar questions such as:

  • Merge Objects
  • How can I merge properties of two JavaScript objects dynamically?
about 4 years ago · Juan Pablo Isaza Report

0

hi everyone if any one have same problem here is the solution

let data = {
  
  ok123b:{
    name:'shanu'
},
   of123b:{
    name:'rahul'
},
   og1453jdfk:{
    name:'ak'
},
   ok1kjjdde23b:{
    name:'man'
}
  
  
}
let r=Object.values(data);


let result =r.map((el) =>el.name)
console.log(result);

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!