title: Multiple conditions in if statement on both sides of the logical operator
body: <p>I was experimenting with having multiple arguments in an if statement on both sides of the logical operator. I first started with the || operator, which worked as expected:</p>
  
  <pre><code>var a = 'apple', b = 'banana', c = 'cherry';
  
  if (a == 'banana' || a == 'apple' || b == 'banana' || b == 'apple') {
      console.log('example 1') // returns
  }
  
  if ((a || b) == 'banana' || (a || b) == 'apple') {
      console.log('example 2') // returns
  }
  
  if (a == ('apple' || 'banana') || b == ('apple' || 'banana')) {
      console.log('example 3') // returns
  }
  
  if ((a || b) == ('apple' || 'banana')) {
      console.log('example 4') // returns
  }
  </code></pre>
  
  <p>So far, no unexpected results.
  However, when following a similar structure when replacing the || operator for the &amp;&amp; operator, things don't quite work as I expect them to.</p>
  
  <pre><code>if ((a == 'banana' &amp;&amp; b == 'apple') || (a == 'apple' &amp;&amp; b == 'banana')) {
      console.log('example 5') // returns
  }
  
  if (((a || b) == 'banana') &amp;&amp; ((a || b) == 'apple')) {
      console.log('example 6') // DOESN'T RETURN
  }
  
  if ((a || b) == 'banana') {
      console.log('example 6a') // DOESN'T RETURN - consistent with example 6
  }
  
  if ((a == ('apple' || 'banana')) &amp;&amp; (b == ('apple' || 'banana'))) {
      console.log('example 7') // DOESN'T RETURN
  }
  
  if (a == ('apple' || 'banana')) {
      console.log('example 7a') // returns - inconsistent with example 7
  }
  
  if (b == ('apple' || 'banana')) {
      console.log('example 7b') // DOESN'T RETURN - inconsistent with example 7a
  }
  
  if ((a &amp;&amp; b) == ('apple' || 'banana')) {
      console.log('example 8') // DOESN'T RETURN
  }
  
  if ('apple' == (a || b) &amp;&amp; 'banana' == (a || b)) {
      console.log('example 9') // DOESN'T RETURN
  }
  </code></pre>
  
  <p>Now, I am wondering: is there a flaw in my logic or can it just not be done this way? My aim is to write these if statements as short as possible, for the purpose of readibility and maintainability. Clearly I am just exploring possibilities.</p>
  
  <p>Does anyone know any way to go about this? Especially example 7/7a/7b seems peculiar to me because it yields inconsistent results despite a similar structure<a href="http://jsfiddle.net/7yy8J/" rel="nofollow"> [Fiddle]</a></p>