I have an object as shown:
const arr = [
{
name: 'FolderA',
child: [
{
name: 'FolderB',
child: [
{
name: 'FolderC0',
child: [],
},
{
name: 'FolderC1',
child: [],
},
],
},
],
},
{
name: 'FolderM',
child: [],
},
];
And I have path as string:
var path = "0-0-1".
I have to delete the object:
{
name: 'FolderC1',
child: [],
},
Which I can do so by doing,
arr[0].child[0].splice(1, 1);
But I want to do it dynamically. Since path string can be anything, I want the above '.' operator and splice definition to be created dynamically to splice at particular place.