showing results for - "get object field from variable name javascript"
Magdalena
23 Mar 2020
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)