I've read this existing question on stackoverflow.
My target is to set a property on a "nested Property and set a new Value (without eval!):
What i have is a dynamic string as example : “A.B.C
”
And a JSON Object:
var obj ={
A: {
B: {
C: 23
C1: {}
}
}
}
Now i want to access this property and set it:
If the string has a fixed amount of properties i can just write:
obj[prop1][prop2][prop3] = 42
What would be the way to make this dynamic, so when passing “A.B” the object at B is replaced?