Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@ doesn't do anything in ECMA262. The document uses it as a placeholder for different operators that use the same syntax. For example, they describe compound assignment such as <code>foo @= bar</code> instead of indicating all of the compound assignment operators.</p> <p>Compound assignment operators are those such as <code>x += 1</code>, except there are quite a few of them, thus, use of the @ sign to represent all of them symbolically in the manual only, nothing in code.</p> <p>As Eli Grey points out, this is a feature that exists in <em><a href="https://secure.wikimedia.org/wikipedia/en/wiki/E4X" rel="nofollow">EcmaScript for XML</a></em>, often nicnamed <em>E4X</em>, offically named ECMA-357.</p> <p>It's important to note that E4X support is presently not common everywhere, and not really the most suitable standard "for the open web", as the WikiPedia article states:</p> <blockquote> <p>E4X <strong>is supported</strong> by Mozilla's <strong>Rhino</strong>, used in <strong>OpenOffice</strong>.org and several other projects, and <strong>SpiderMonkey, used in Firefox, Thunderbird, and other XUL-based applications.</strong> It is also supported by Tamarin, the JavaScript engine used in the Flash virtual machine. It is <strong>not supported</strong> by Nitro (<strong>Safari</strong>), V8 (Google <strong>Chrome</strong>), <strong>Opera</strong>, nor <strong>Internet Explorer</strong>.<a href="https://secure.wikimedia.org/wikipedia/en/wiki/E4X" rel="nofollow">1</a></p> </blockquote> <p>From the E4X example on the page, </p> <p>You can assign a variable some XML data (in much the same way we can use JSON syntax to assign objects)</p> <pre><code>var sales = &lt;sales vendor="John"&gt; &lt;item type="peas" price="4" quantity="6"/&gt; &lt;item type="carrot" price="3" quantity="10"/&gt; &lt;item type="chips" price="5" quantity="3"/&gt; &lt;/sales&gt;; </code></pre> <p>Then, to get an attribute value, such as the value of "vendor", we can do</p> <pre><code>alert( sales.@vendor ); </code></pre> <p>And get back "John" in the alert box.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload