Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a new feature of JavaScript 1.7 called <a href="https://developer.mozilla.org/en/New_in_javascript_1.7#Destructuring_assignment_(Merge_into_own_page.2Fsection)" rel="noreferrer">Destructuring assignment</a>:</p> <blockquote> <p>Destructuring assignment makes it possible to extract data from arrays or objects using a syntax that mirrors the construction of array and object literals.</p> <p>The object and array literal expressions provide an easy way to create ad-hoc packages of data. Once you've created these packages of data, you can use them any way you want to. You can even return them from functions.</p> <p>One particularly useful thing you can do with destructuring assignment is to read an entire structure in a single statement, although there are a number of interesting things you can do with them, as shown in the section full of examples that follows.</p> <p>You can use destructuring assignment, for example, to swap values:</p> <pre><code>var a = 1; var b = 3; [a, b] = [b, a]; </code></pre> <p>This capability is similar to features present in languages such as Perl and Python.</p> </blockquote> <p>Unfortunately, according to <a href="http://en.wikipedia.org/wiki/JavaScript#Versions" rel="noreferrer">this table of versions</a>, JavaScript 1.7 has not been implemented in Chrome. But it should be there in:</p> <ul> <li>FireFox 2.0+</li> <li>IE 9</li> <li>Opera 11.50. </li> </ul> <p>Try it for yourself in this jsfiddle: <a href="http://jsfiddle.net/uBReg/" rel="noreferrer">http://jsfiddle.net/uBReg/</a></p> <p>I tested this on Chrome (failed), IE 8 (failed), and FireFox 5 (which worked, per the wiki table).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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