title: Is returning out of a switch statement considered a better practice than using break?
body: <p><strong>Option 1 - <code>switch</code> using <code>return</code>:</strong></p>
  <pre class="lang-js prettyprint-override"><code>function myFunction(opt) {
    switch (opt) {
      case 1: return &quot;One&quot;;
      case 2: return &quot;Two&quot;;
      case 3: return &quot;Three&quot;;
  
      default: return &quot;&quot;;
    }    
  }
  </code></pre>
  <p><strong>Option 2 - <code>switch</code> using <code>break</code>:</strong></p>
  <pre class="lang-js prettyprint-override"><code>function myFunction(opt) {
    let retVal = &quot;&quot;;
  
    switch (opt) {
      case 1: 
        retVal = &quot;One&quot;;
        break;
      case 2: 
        retVal = &quot;Two&quot;;
        break;
      case 3: 
        retVal = &quot;Three&quot;;
        break;
    }
  
    return retVal;
  }
  </code></pre>
  <p>I know that both work, but is one more of a best practice?  I tend to like Option 1 - <code>switch</code> using <code>return</code> best, as it's cleaner and simpler.</p>
  <hr />
  <p><em><strong><a href="http://jsfiddle.net/CodeMaverick/NENjc/" rel="noreferrer">Here is a jsFiddle of my specific example using the technique mentioned in @ic3b3rg's comments</a></strong></em>:</p>
  <pre class="lang-js prettyprint-override"><code>let SFAIC = {};
  
  SFAIC.common = {
    masterPages: {
      cs: &quot;CS_&quot;,
      cp: &quot;CP_&quot;
    },
    contentPages: {
      cs: &quot;CSContent_&quot;,
      cp: &quot;CPContent_&quot;    
    }
  };
  
  function getElementPrefix(page) {
    return (page in SFAIC.common.masterPages)
      ? SFAIC.common.masterPages[page]
      : (page in SFAIC.common.contentPages)
        ? SFAIC.common.contentPages[page]
        : undefined;
  }
  </code></pre>
  <p>To call the function, I would do so in the following ways:</p>
  <pre class="lang-js prettyprint-override"><code>getElementPrefix(SFAIC.common.masterPages.cs);
  getElementPrefix(SFAIC.common.masterPages.cp);
  getElementPrefix(SFAIC.common.contentPages.cs);
  getElementPrefix(SFAIC.common.contentPages.cp);
  </code></pre>
  <p>The problem here is that it always returns undefined. I'm guessing that it's because it's passing in the actual value of the object literal and not the property.  What would I do to fix this using the technique described in <strong>@ic3b3rg's</strong> comments?</p>