Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda