在JavaScript数组中使用特殊字符访问格式化值

4
我收到了一个API调用的响应对象。
该对象如下所示: enter image description here 现在,当我尝试使用response._modifiedby_value时,我得到了正确的响应。但是,当我尝试使用response.createdby_value@OData.Community.Display.V1.FormattedValue时,我会收到以下错误:
Uncaught SyntaxError {message: "Unexpected token ILLEGAL"}
1个回答

4
那是因为“@”是一个特殊字符,所以你不能这样做:
response.createdby_value@OData = 2;

但是相反的是
response["createdby_value@OData"] = 2;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接