I find the following code in some file:
var node = <title />;
node.@name = "titleName";
The node is
<title>
<name>titleName<name/>
</title>
So What's the .@
operator meaning?
I find the following code in some file:
var node = <title />;
node.@name = "titleName";
The node is
<title>
<name>titleName<name/>
</title>
So What's the .@
operator meaning?
This looks like ECMAScript for XML (E4X), an extension for ECMAScript (on which JavaScript is based). It was standardized in ECMA-357, but it was not widely adopted by the major browser vendors, and was dropped from later ECMAScript standards. However, it is still supported by some engines, including ActionScript 3.0.
It's used for working with XML more gracefully. The .@
syntax references an XML attribute within an XmlNode
, and in this case, node.@name = "titleName"
sets the attribute name
on node
to the value "titleName"
.
© 2022 - 2024 — McMap. All rights reserved.
var node = <title />;
, and I can't imagine that would be valid in anything. – Shepard