This is a part of a large function, but to put it simply:
var round1 = {gg: "wp"};
var round2 = round1;
eval('round2.gg="bp"')
This gives:
round2 == {gg: 'bp'}
But also changes:
round1 == {gg: 'bp'}
How to get around this ?
Edit: why I need eval ?
As a part of my function, i have the paths of the bigobject recorded as strings in an array, such that i can use eval to change the value of a specific property and copy it in a cloned object.
Example:
var bigobject = {
a: { x: "1", y: "2" },
//b: similar
}
var pathobject [".a.x",".a.y",".b.x",".b.y"]
// This eval is run in loop, so i = index of loop. but lets say i=0
var temp_object = bigobject;
var i=0;
eval('temp_object' + pathobject[i] + '=' + '5');