I have an object like this:
var myObj = {
first: {
sub: {
level: "some text",
level2: "some more text"
},
sub2: {
level3: "Something"
}
},
second: {
stuff: "More stuff...lots of stuff"
}
}
what I want to be able to do is say
delete myObj.first.sub.level
But I won't know what is being passed, or how many levels deep I need to go in order to remove the correct property, meaning it could simply be:
Storage.removeItem('myObj.first'); // This is currently working
Or something more complex:
Storage.removeItem('myObj.first.sub2.level3'); // This doesn't work because I'm more than 1 level into the object.
I'm kind of stuck, because I can get to the point where I have the key "level3" and it's property "Something", but I can't figure out how to back-step correctly in order to delete the full section of that object.
I need to replicate it's place in myObj so I can delete the full passed object.
'myObj.first.sub.level3'
If that makes sense...