Hi Guys,
I have a array with unknown amount of data in it and each data object may have many subitems,
var array = [
{
item: 1,
subItem: [
{
item: 2,
subItem: [
{
item: 2,
subItem: [
{ item: 2 },
{ item: 3 },
{ item: 4 }
]
},
{ item: 3 },
{ item: 4 }
]
},
{ item: 3 },
{ item: 4 }
]
},
{
item: 1,
subItem: [
{
item: 2,
subItem: [
{
item: 2,
subItem: [
{ item: 2 },
{ item: 3 },
{ item: 4 }
]
},
{ item: 3 },
{ item: 4 }
]
},
{ item: 3 },
{ item: 4 }
]
}
];
I have target in string format
let target = 'array[0].subItem[2]';
I need to update this target in array
I can't loop because target will be random and it can 100th child.
Please help me update this target with this update
let update = {item: 'newitem'};
I can update target by
target = update;
but now how will i update value in main array
? jsfiddle