I am trying to remove a property from the object by key.
It's very important to notice that I have the key in my variable, and i am unable to do the following:
delete obj.test.a
This is my code (which doesn't work)
var obj = {
b: 2,
test: {
a: 1
}
}
var abc = 'test.a';
delete obj[abc];
console.log(obj);
How can I acheive deleting obj.test.a without hardcoding, and instead taking the key from variable.