I was trying to create a function able to set a certain value of an object, having the "path" of the property:
reflectionSet = function(obj, propString, value) {
var current = obj;
var splitted = propString.split('.');
splitted.forEach(function(k) {
current = current[k];
})
current = value;
}
var test = {
a: {
s: 'asd',
g: 'asasdasdd'
}
};
reflectionSet(test, 'a.g', "otherValue");
and it should become:
{
a: {
s: 'asd',
g: 'otherValue'
}
}
Unfortunately this doesn't work at all.. Thanks