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

213
Vistas
How to get a data from an object inside of a function (JS)

let's say that I have a function that includes an object

const someFunc =props=> ({
styles:{
somedata: 'somedata:',
},
infoSectionValue: {
 bold: true,
},
images:{
 donut: props.donut_base64,
icon: 'some icon'
},
 content: [1,2,3]
}
})`
now I want to get the icon using object destruction
`const {images :{ icon }} = someFunc()
console.log(icon)

ERROR : props not define it didn't work while there are other objects or props included how can I get the icon in this case?

this is only way only have worked, if the function is to maintain the object:

const someFunc =props=> {
images:{
icon: 'some icon'
}
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You probably mean object destructuring, not destruction.

This works (you're missing parenthesis):

Edit: There are multiple errors in your example code, this shows a couple of options:

 const someFunc = props => ({
    foo: 87,
    bar: { foo: 'hi' }

});

const { bar: { foo: msg } } = someFunc();

console.log(msg);

const { bar: bar } = someFunc();

console.log(bar)
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