S
surfintheusa
Hi all,
Given the following:
var obj = new Object();
obj.prop1 = 1;
obj.prop2 = 2;
obj.subobj = new Object();
obj.subobj.prop3 = 3;
I'd like to automatically access the right property given it's name
like this:
var propName = whatever; // Can be "prop1", "prop2" or "prop3".
var propValue = obj["" or "subobj"][propName];
Technically, in the case of "prop1" or "prop2" the first square
brackets should disappear. Is there a way to do that?
Thanks!
Terry
Given the following:
var obj = new Object();
obj.prop1 = 1;
obj.prop2 = 2;
obj.subobj = new Object();
obj.subobj.prop3 = 3;
I'd like to automatically access the right property given it's name
like this:
var propName = whatever; // Can be "prop1", "prop2" or "prop3".
var propValue = obj["" or "subobj"][propName];
Technically, in the case of "prop1" or "prop2" the first square
brackets should disappear. Is there a way to do that?
Thanks!
Terry