I'm a bit puzzled by the current situation where:
let groupdetails = {
groupName: "",
};
const groupsArray = [];
groupdetails.groupName = 'A'
groupsArray.push(groupdetails)
groupdetails.groupName = 'B'
groupsArray.push(groupdetails)
console.log(groupsArray)
The outcome I am seeing is:
[ { groupName: "B" }, { "groupName": "B" } ]
My expectation was:
[ { groupName: "A" }, { "groupName": "B" } ]
Not sure what mistake I might be making?