I need to create a variable variable name in JS...
obj = {};
obj.fooonex = {};
obj.fooonex.start = 1;
obj.fooonex.end = 2;
a = "foo";
b = "one";
c = "x";
test = a + b + c;
alert(obj.test.start);
I want the result to be "1"
fiddle here: http://jsfiddle.net/mR6BH/
You need to do:
alert(obj[test].start);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With