title: Understanding conditional operator and assignment in condition in code snippet
body: <p>I'm trying to understand how the third line in this code snippet (the assignment <code>value = f</code> in the condition of the conditional expression) is working:</p>
  
  <pre><code>someProp(propName, f) {
    let prop = this._props &amp;&amp; this._props[propName], value
    if (prop != null &amp;&amp; (value = f ? f(prop) : prop)) return value
    ...
  }
  </code></pre>
  
  <p>In this example, <code>value</code> is undefined at the <code>console.log(value)</code> statement:</p>
  
  <pre><code>let f = 42;
  value = f ? console.log('true') : console.log('false');
  console.log(value);
  </code></pre>
  
  <p>It seems to me that the <code>value</code> variable returned on the third line of the first snippet would always be undefined. What am I missing? The snippet is from production code in an open source project I'm studying.</p>
  
  <p>Also, <code>this._props</code> is an object. Why is the author using <code>if (prop != null &amp;&amp; ...</code> to test if the props object exists, rather than just something like <code>if (prop &amp;&amp; ...</code> ? And am I right in thinking that this is typical code of more experienced developers, or would others write it differently?</p>