Answers for "get object field from variable name javascript"

0

get object field from variable name javascript

var something = {
  bar: 'foo'
};
var foo = 'bar';

// both x = something[foo] and something[foo] = x work as expected
console.log(something[foo]);
console.log(something.bar)
Posted by: Guest on May-16-2021

Code answers related to "get object field from variable name javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language