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

150
Vistas
How to Perform 2 join operation on an Object array?
const rows = [
    ["Name", "City", "Info"],
    ["name1", "city1", "some other info"],
    ["name2", "city2", "more info"]
];
let csvContent = rows.map(e => e.join(",")).join("\n");

Similarly how can I implement the same on an Object array for example

const rows = [
        {name:"FirstName", city:"City", info:"Info"},
        {name:"LastName", city:"City", info:"Info"},
    ];
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First you can Array#reduce it, saving the Object.keys as the first header row, then creating the array structure. Finally map all that just like your first example.

const rows2 = [{
    name: "FirstName",
    city: "City",
    info: "Info"
  },
  {
    name: "LastName",
    city: "City",
    info: "Info"
  },
];

let csvContent2 = rows2.reduce((b, a, i) => {
  if (i === 0) b.push(Object.keys(a))
  return b.concat([Object.values(a)]);
}, []).map(e => e.join(",")).join("\n")
console.log(csvContent2);

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