javascript get object property with variable code example
Example 1: javascript get object property with variable
var person ={"first_name":"Billy","last_name":"Riley"};
var property_name="first_name";
alert(person[property_name]); //Dynamically access object property with bracket notation
Example 2: javascript object string property
// Also useful for dynamic strings, e.g. `thing-${variable}`
myObject['thing'] = true;