I have
let mydata = {
section_a: {
color: "red",
shape: "cube"
},
section_b: {
length: 34
}
}
Now I want to write a function that'll insert a new key/value
at a path that is dynamic and can change from call to call.
let path = "section_b.go.real.deep";
let newKey = "age";
let newVal = 50;
so that mydata becomes:
{
section_a: {
color: "red",
shape: "cube"
},
section_b: {
length: 34,
go: {
real: {
deep: {
age: 50
}
}
}
}
}
Is there any technique to allow something like that? creation of a deep element, along with any potential dynamic hierarchy?