Javascript property from variable

后端 未结 2 1417
既然无缘
既然无缘 2021-01-28 07:26

I have a problem with my JavaScript code. I\'m starting with some more complex things right now, seemed to find some answers on the net, but unfortunately I can\'t get it fixed.

2条回答
  •  情书的邮戳
    2021-01-28 07:41

    Try this

    var oFieldValues = { };
    oFieldValues[ sGetMobileField ] = { Value: ValMob };
    

    You can use variables as property identifiers, but not inside an object literal. You have to create the object first, and may then add dynamic properties using

    obj[ varToHoldPropertyName ] = someValue;
    

提交回复
热议问题