1var person ={"first_name":"Billy","last_name":"Riley"};
2var property_name="first_name";
3alert(person[property_name]); //Dynamically access object property with bracket notation
1var foo = { pName1 : 1, pName2 : [1, {foo : bar }, 3] , ...}
2
3var name = "pName"
4var num = 1;
5
6foo[name + num]; // 1
7
8// --
9
10var a = 2;
11var b = 1;
12var c = "foo";
13
14foo[name + a][b][c]; // bar
1var something = {
2 bar: 'foo'
3};
4var foo = 'bar';
5
6// both x = something[foo] and something[foo] = x work as expected
7console.log(something[foo]);
8console.log(something.bar)