Typical error with Object pass by reference:
when u want to create an array [ { i:0 } , { 1:1 } ]
var obejct = {};
var response =[];
for (let i = 0; i <2; i++){
object.i = i;
response.push(object)
}
console.log(response);// [{i:1},{i:1}]
you will found that both object in the response array will become {i:0} because they are referenced to the same Object.
the right way to implement
var response =[];
for (let i = 0; i <2; i++){
let obejct = {};
object.i = i;
response.push(object)
}
console.log(response);// [{i:0},{i:1}]