I have a object
like this:
{
var: {
foo: '',
foo2: '',
}
}
and a parameter (['var', 'foo2'], newData)
comes to me in a function. What would I have to do to return the original object with var.foo2 = new Data
?
The parameter amount of the array as well as the general object may change: (
I've tried:
let fields = ['var', 'foo2'];
let obj = objOri;
for (let f of fields) {
if (obj.hasProperty(f)) {
obj = obj[f];
}
}
obj = newData;
console.log(objOri);// Sigue saliendo mal :(