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

318
Vistas
why does object.assign not combine all the source objects into the target

my code is :

  return await axios
    .all(requests)
    .then(
      axios.spread(async (...responses) => {
        let fish = [...responses].map((e) => e.data.results);
        let newFish = Object.assign({}, ...fish);
        console.log(fish, 'and', newFish);
      }),
    )

a console.log of fish shows:

[(Object of 100 keys), (Object of 100 keys),(Object of 100 keys),(Object of 70 keys)]

but a console.log of newFish instead of being the desired : (Object of 370 keys)

shows (object of 100 keys)

This suggests object. assign is overwriting instead of combining.

Why does it do this?

I need to do

return Object.addign({},...responses)

and have this combine all the objects into one object

more info:

OBJECT WITH 100 keys:

enter image description here

all objects

enter image description here

All have a unique id and are alphabetically ordered. every value is completely unique.

Object with 100 keys is a combination of the last object with 100 keys and the last object that has only 70 keys. enter image description here

as you can see here in how it adds more after 70 enter image description here

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