So I have an object, say
var obj = {
flowers: {
rose: 'red',
sunflower: 'yellow',
},
vegetables: { ... }
}
Is there anyway to get the keypath for red to return as obj['flowers']['rose'] ? (There are no possibility of duplicate values or keys in my actual object so that wont be a problem)
I have tried to use Object.keys, but that outputs everything since it doesnt have an option to put specific values.
Tried to use for loop, but it would have worked if the nest was just at single level.
I have also tried looking for similar questions, but couldn't make out anything from them. Please throw some light.