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

244
Vistas
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
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