title: Puzzled with the workings of these variable assignments?
body: <p>Tried to figure out the working logic behind the results. I couldn't.</p>
  
  <p>Could someone please help explain how Javascript works the output of each of the 4 situations and the reason behind it?</p>
  
  <p>I think the 1st and 2nd are similar situations.</p>
  
  <p>Thanks</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var num = (1, 2, 3);    // num = 3 (last number returned, No error generated)
     console.log(num)
  
  y = (1, 2, 3);          // y = 3  (last number returned, No error generated)
     console.log(y)
  
  z = 1, 2, 3;            // z = 1  (first number returned, No error generated)
     console.log(z)
  
  // Uncomment the following to run: (gives an error)
  
  //var m = 1, 2, 3;        // Error: Unexpected number </code></pre>
  </div>
  </div>
  </p>