[removed] access to an object's member by name

前端 未结 2 1219
面向向阳花
面向向阳花 2020-12-11 18:21

I have an object called themesData:

var themesData = {}
themesData.a = { key: \"value\" }; 
themesData.b = { key: \"another value\"};

2条回答
  •  情书的邮戳
    2020-12-11 19:07

    You can do it in this way:

    var member="a"; //or B
    var rightMember=themesData[member].key;
    

提交回复
热议问题