Possible Duplicate:
Get property of object in JavaScript
If I have the following:
var test ='bar';
var sections = {
foo: 'value1',
bar: 'value2',
baz: 'value3'
};
I can use sections.foo to output 'value1'. Thats fine. However what if I want to get the value from sections according to another variable. Although this doesnt work what I mean is something like:
sections.test
Where test is the variable declared earlier, so the value returned would be 'bar'.
I dont work a awful lot with js so any help would be appreciated :) .. or if im approaching this the wrong way, feel free to say.
thanks
-->EDIT
The reason I wanted to do this is because the variable 'test' will be coming from the url and then I just wanted to load up further information depending on what page the user was on. :)