I have a collection of objects: https://i.sstatic.net/XNrcU.png
Within the collection, I wished to include an additional property to the objects.
To achieve this, I utilized the map function:
returnArray = returnArray.map((obj) => {
obj.active = "false";
return obj;
});
https://i.sstatic.net/PpiYO.png
At a later stage, I intend to modify the value of the newly added 'active' property to a different value ("true") within a separate function. However, there seems to be an issue with the value not updating.
When attempting to alter the value of a pre-existing property in the original array, the update is successful.
var array = getarrayfunction();
array[index].active = "test"; <-- Not working
array[index].originalProperty = "test"; <-- Works fine
https://i.sstatic.net/HoTIz.png
Could someone shed light on why this is happening and suggest a solution?
Appreciate your help!