title: Nested (Condition) ? true:false statements in JavaScript
body: <p>In the following code snippet,</p>
  
  <pre><code>var paintMode = data.hasOwnProperty('regions') ?
          'regions' : data.hasOwnProperty('vpcs') ?
          'vpcs' : data.hasOwnProperty('zones') ? 
          'zones' : data.hasOwnProperty('subnets') ? 
          'subnets' : data.hasOwnProperty('clusters') ? 'clusters' : null;
  </code></pre>
  
  <p>I've used a deeply nested <code>(condition) ? true : false</code> -- is this acceptable? is it optimized? If its bad is there an alternative?</p>
  
  <p>It is used inside a recursive function which does a few SVG operations, here's the function snippet if you are curious.</p>
  
  <pre><code>function paintGroups(data) {
      var paintMode = data.hasOwnProperty('regions') ? 'regions' : data.hasOwnProperty('vpcs') ? 'vpcs' : data.hasOwnProperty('zones') ? 'zones' : data.hasOwnProperty('subnets') ? 'subnets' : data.hasOwnProperty('clusters') ? 'clusters' : null,
          depth = data[paintMode].length,
          i,
          Shape; //= raphealObj.rect();
  
      // Register stacking order
      // Paint a shape with styles based on paintMode
      // Store its id &amp; Label for other ops.
  
      if(paintMode) {
          for(i = 0; i &lt; depth; i++) {
              paintGroups(data[paintMode][i]);
          }
      }
  
      // to reverse the order of paint - place your statements here
  }
  </code></pre>