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

286
Views
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 answers
Answer question

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 Report

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 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!