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

105
Vistas
How to merge 2 arrays of object with extra matching

I actually don't know what this is called, hence the "extra matching" in the title

I have 2 arrays of objects

[{player_1: 'adeshina'}, {player_1: 'MindReaper'}]

and

[{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]

How can I merge it to become {player_1: 'adeshina', player_2: 'thinkerbull'}, {player_1: 'MindReaper', player_2: 'AfroGamer'} ?

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

0

You can use map() to loop through the arrays and merge the objects,

like this:

const arrayOne = [{player_1: 'adeshina'}, {player_1: 'MindReaper'}]
const arrayTwo = [{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]

const newArray = arrayOne.map( (e, index) => ({...e, ...arrayTwo[index]}));
about 4 years ago · Juan Pablo Isaza Denunciar

0

It's actually called "zipping". You wanna zip two arrays.

It can be done using map:

var a = [{player_1: 'adeshina'}, {player_1: 'MindReaper'}]
var b = [{player_2: 'thinkerbull'}, {player_2: 'AfroGamer'}]


var c = a.map(function(e, i) {
  return [e, b[i]];
});

console.log(c)

A shorter version would be:

c = a.map((e, i) =>[e, b[i]]);
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