javascript - How to get the object property dynamically in the run time using the name of the property -
i have object structured below.

now intention capitals/state value on run time dynamically using property name, example.
var propertyname='capitals'; json.parse(valuelist)[0].propertyname; how achieve this. thanks.
you can use bracket notation([]) object selector
var propertyname='capitals'; json.parse(valuelist)[0][propertyname]; for more bracket notation : visit here
Comments
Post a Comment