is there anyway in JavaScript to print complete path of a nested object attribute. For example assume I have a below object
var items = [ {
2019 : {
December: {
Groceries : {
KitchenNeeds : {
[
"Milk",
"cheese"
]
}
}
}
}
}];
To access Milk, I can access as items[0].2019.December.Groceries.KitchenNeeds[0]
But is there any way, if I choose "Milk" it should print all the tree path thats needs to be travelled to get "Milk".