tags:

views:

109

answers:

2

I have an object called "themesData".

var themesData = {}
themesData.a = { key: "value" }; themesData.b = { key: "another value"};

and I want to access one of the members by its name - I get a string which contains either "a" or "b" and I want to get the appropriate member's value.

I'd be happy to get some help on that. Thanks!

+4  A: 

themesData["a"].key does what you need and is equivalent to themesData.a.key, still the "array index style" notation allows you to dynamically generate index names.

naivists
+2  A: 

You can do it in this way:

var member="a"; //or B
var rightMember=themesData[member].key;
mck89