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

243
Views
Create an array of objects, having an array of data in JavaScript

this time I come to you for the following, I want to create an object in JS with data that comes to me from an array, the array contains the following data:

const columnsTable = [
  "id",
  "name",
  "age"
];

Really the problem is that when this happens in vuejs it returns me as follows and it is exactly the same code, any idea? what is selected is the return of my computed method My computed method is as follows: method computed My computer method has the same native js code and it returns me differently. Would it be good to open another question with this topic?

The array of objects that I want to create with the above array must have the following structure:

 columns: [
        {
          name: 'id', align: 'center', label: 'id', field: 'id'
        },
        {
          name: 'name', align: 'center', label: 'name', field: 'name'
        },
        {
          name: 'age', align: 'center', label: 'age', field: 'age'
        }
      ]
    } 

Where each object represented in the object array has a value from the columsTable array in name, label and field.

I am trying as follows but I am not successful:

var columnsTable = [
  "id",
  "nombre",
  "edad",
];

var colums = [];

columnsTable.forEach((column) => {
  colums.push({
    name: column,
    align: 'center',
    label: column,
    field: column
  });
  console.log(colums);
});

Since this at the end returns all the values of my array within a property of my object. From now on I thank you, any contribution would be very helpful.

about 4 years ago · Juan Pablo Isaza
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!