title: Assignment Operation Value in JavaScript
body: <pre><code>&lt;!-- HTML --&gt;
  &lt;div id="target"&gt;&lt;/div&gt;
  
  // JavaScript
  function MyObject() {}
  
  var $my_div = $('#target'),
      data;
  $my_div.data('extra', (data = new MyObject()));
  </code></pre>
  
  <p>In JavaScript, the expression e.g. <code>(data = new MyObject())</code> evaluates to <em>MyObject</em> object; whereas, in a language like C, the value of an expression is always <code>true</code>.</p>
  
  <p>In the code snippet above, is <code>(data = new MyObject())</code> only meant for a shortcut of doing exactly the same thing as the following?</p>
  
  <pre><code>...
  var $my_div = $('#target'),
      data = new MyObject();
  $my_div.data('extra', data);
  </code></pre>
  
  <p><strong>Clarifications</strong>:
  I initially wasn't sure what <code>(data = new MyObject())</code> actually does. I was wondering why not separating that expression in its own line, rather than doing it in <code>.data()</code>. The question was whether there were any differences between doing that expression in <code>.data()</code> or separately.</p>