title: Can someone explain why the conditional operator and the assignment operator behave strangely when used together?
body: <p>Can someone explain why the below code will not give an error:</p>
  
  <pre><code>var x;
  false ? null : x = 1;
  </code></pre>
  
  <p>According to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence" rel="nofollow noreferrer">MDN-operator precedence</a> the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator" rel="nofollow noreferrer">conditional operator</a> has a higher operator precedence than the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators" rel="nofollow noreferrer">assignment operator</a>, 
  which means that the above code should give an error because it's actually parsed like:</p>
  
  <pre><code>var x;
  (false ? null : x) = 1
  </code></pre>
  
  <p>but it didn't give an error whereas this works as expected:</p>
  
  <pre><code>var x;
  x = 1 ? alert(x) : null;
  </code></pre>
  
  <p>The above code is parsed like:</p>
  
  <pre><code>var x;
  x = (1 ? alert(x) : null);
  </code></pre>
  
  <p>because the conditional operator has a higher precedence, but why in my very first code will it not give an error if the conditional operator has a higher precedence than the assignment operator? </p>