i am new to JS objects. I have such code
var foo = {
bar0: {
barr0: function() {//doo stuff}
barr1: function() {//doo stuff}
},
bar1: {
barr0: function() {//do stuff}
barr1: function() {//do stuff}
},
bar2: function() {//do stuff}
}
now i have this variable myVar that holds the 'name' of any of the above in the format they would be called. like it can have bar0.barr1 or bar2 or mention to any other of the above objects. foo will not be a part of myVar because it is common for every call. One possible solution is to use eval but i would like to avoid it if possible.
if the object was one dimensional i would have used foo[myVar]() but this is now multidimensional and i hav no idea how should i call it.