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

293
Vistas
Array.from(Object).forEach not working with vue.js

I create object like this on my data() in vue.js 2 CLI:

data(){
    return{
        user: {
            user_mail: '',
            user_password: '',
            user_confirm_password : '',
            user_phone : '',
            user_fname: '',
            user_lname: '',
        },
    }
},

Now I'm trying to print this object on a the log useing mounted function:

mounted() {
    console.log(this.user)
}, 

It works fine. The problem starts when I trying to go through it with forEach:

mounted() {
    Array.from(this.user).forEach((value) => {
        console.log(value)
    });
},

In this situation I don't get any output on my log. Any suggestions? Thanks :)

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Array from creates an array from an iterable, which does not work on plain objects.

The Array.from() static method creates a new, shallow-copied Array instance from an array-like or iterable object.

You could use Object.values, Object.entries or Object.keys

Object.values(this.user).forEach((value) => {
  console.log(value)
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

The Array.from() cannot create an array from your object. Instead of it, you could just use the old simple way:

for (const key in this.user) {
  console.log(this.user[key]);
}
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