I have an array
fruit={sweet:'apple',dry:{f1:'raisin',f2:'almond'},sour:'strawberry'}
it contains simple and nested objects as items
i can reference f1 using bracket notation like fruit[0]["dry"]["f1"]
but i have a string variable that has the value var str="dry.f1"
value of "str"
changes on runtime it could be "sweet"
or "dry.f1"
or "sour"
how do i reference the array item using "str"
if the value of str is either "sweet"
or "sour"
fruit[str]
works fine
we can get the value of f1 using fruit[0].dry.f1
but i need to access it using the variable str