方括号前的 at 符号
At-sign before square brackets
我目前正在 Demandware 中维护一些 DS/JS 代码,我刚刚发现:
var XmlReponse : XML = new XML(result.object.text);
status = XmlReponse.@["STATUS"];
这个不寻常的“@[...]”语法有什么作用?
它可能与 ECMA-357 规范(又名 "E4X")有关,但我不确定:在 DW docs(需要凭据)中,据说:
"You can read values from an XML object the same way you would from standard ECMAScript objects"
var quantity = order.item(0).@quantity;
var singleItem = order.item.(@quantity == 1);
这似乎解释了 @
但让我对以下方括号表示怀疑,也许是某种动态 属性 ?
谢谢:)
我目前正在 Demandware 中维护一些 DS/JS 代码,我刚刚发现:
var XmlReponse : XML = new XML(result.object.text);
status = XmlReponse.@["STATUS"];
这个不寻常的“@[...]”语法有什么作用?
它可能与 ECMA-357 规范(又名 "E4X")有关,但我不确定:在 DW docs(需要凭据)中,据说:
"You can read values from an XML object the same way you would from standard ECMAScript objects"
var quantity = order.item(0).@quantity;
var singleItem = order.item.(@quantity == 1);
这似乎解释了 @
但让我对以下方括号表示怀疑,也许是某种动态 属性 ?
谢谢:)