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

132
Vistas
Iterating through and object property and putting the values inside variables in javascript

I'm trying to iterate through an object using the for...in loop to get the values of all its properties and put them inside variables. I'm stumbling on this.

What I would like to do is loop through the object properties, put the value inside a variable of the same the name as the property to use on them on another variable


somePromise.then(response => {  

  for (let property in response) {
    property = response[property]  // this doesn't work cause reuses the same variable
  }

  /// I take the value of each property from the loop and pass it down 
  user.updateInfoFromOldDB(
    userID,
    nguid,
    property1 
    property2,
    property3
    property4,
  )

  ...ommited_code
})
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Did you try Object.values()?

somePromise.then(response => {  

  const valuesArr = Object.values(response);

  /// I take the value of each property from the loop and pass it down 
  user.updateInfoFromOldDB(
    ...valuesArr
  )

  ...ommited_code
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can directly access the properties from the response:

somePromise.then(response => {  
  user.updateInfoFromOldDB(
    response.userID,
    response.nguid,
    response.property1,
    response.property2,
    response.property3
    response.property4,
  )
})

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