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

58
Views
La nueva matriz recibe solo el último elemento del ciclo forEach

Estoy tratando de manipular diferentes matrices, por lo que hay una matriz original, hay un modelo de objetos JSON que la nueva matriz debe ser poblada por este modelo de objetos, y necesito transformar los datos de la matriz original en esta nueva matriz, pero para algunos razón cuando trato de insertar el nuevo objeto en la nueva matriz, solo el último elemento se inserta y se repite hasta el final, de la siguiente manera:

 this.customersTable.forEach((costumer) => { const newObj = this.objModel; Object.keys(newObj).map((key) => { newObj[key] = costumer[key]; if (newObj[key] === undefined || newObj[key] === null) { newObj[key] = ''; } }); this.exportData.push(newObj); this.exportData is any[] type console.log(newObj); console.log(this.exportData) });

Esta identificación: 6898 es el último elemento de la matriz original, pero como puede ver, el objeto que se inserta en esta nueva matriz es correcto...

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!