How to get the value of a property using variable as name?

3

How to get it to fetch the property ABC instead of A ? Considering this code:

A = 'ABC';    
alert(LANG.A);
    
asked by anonymous 07.06.2015 / 02:24

1 answer

4

The LANG.A of your example looks for a property named A on object LANG . Already LANG[A] looks for a property whose name is the value of the variable A , that is, 'ABC' - so it equals LANG.ABC . I think you're wanting that second case.

    
07.06.2015 / 03:16