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

143
Views
Javascript .push() issued replaced the smaller index with same object properties

I code in javascript, i would like to declare some variables from string and put it into an array by using .push() function.

I expected it returns :

[
  { member_id: '472030702465056800' },
  { member_id: '925009553802817500' },
  { member_id: '668595198309171200' }
]

But what i got was unexpected. It replaced all the array index with the new object. Here is my code :

let merits_id_cather = [ 472030702465056800, 925009553802817500, 668595198309171200 ]
let merits_final_container = {};
let merits_final_array = [];
for (let i = 0; i < merits_id_cather.length; i++) {
    merits_final_container["member_id"] = `${merits_id_catcher[i]}`;
    merits_final_array.push(merits_final_container);
    console.log(merits_final_container);
    console.log(merits_final_array);
}

it returns in console : console returned

What was wrong with the array? Or is there any mistake i made?

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!