There are many solutions for checking / accessing an object literal providing a dot notation string, but I need to make a SET object literal based on a dot notation string. It is very important why I need to do this, and if this is not possible, I will come up with a different solution.
Here is what I would like to do:
var obj = {
'a': 1,
'b': 2,
'c': {
'nest': true
}
};
I need a function that will work something like this:
setDepth(obj, 'c.nest', false);
This will change obj to this:
var obj = {
'a': 1,
'b': 2,
'c': {
'nest': false
}
};
I tried an hour and still could not find a good solution. Another help would be greatly appreciated!
source
share