Giving the following example:
const a = {
b: {
c: null
}
};
let d = ["b", "c"];
let reference = a;
d.forEach(key => (reference = reference[key]));
reference = "fe";
console.log("With a reference to the object deep key.");
console.log(a);
a["b"]["c"] = "fe";
console.log("Directly setting it, what I want.");
console.log(a);
Would it be possible to change the value of c
with a reference to it? This is the closest I am but it obviously stores the null
value on it.