title: Performance of if-else, switch or map based conditioning
body: <p>I was wondering about the performances of the following implementations of conditional structs in javascript. </p>
  
  <p><strong>Method 1:</strong> </p>
  
  <pre><code> if(id==="camelCase"){
      window.location.href = "http://www.thecamelcase.com";
  }else if (id==="jsFiddle"){
      window.location.href = "http://jsfiddle.net/";
  }else if (id==="cricInfo"){
      window.location.href = "http://cricinfo.com/";
  }else if (id==="apple"){
      window.location.href = "http://apple.com/";
  }else if (id==="yahoo"){
      window.location.href = "http://yahoo.com/";
  }           
  </code></pre>
  
  <p><strong>Method 2:</strong></p>
  
  <pre><code>switch (id) {
  case 'camelCase':
      window.location.href = "http://www.thecamelcase.com";
      break;
  case 'jsFiddle':
      window.location.href = "http://www.jsfiddle.net";
      break;
  case 'cricInfo':
      window.location.href = "http://www.cricinfo.com";
      break;
  case 'apple':
      window.location.href = "http://www.apple.com";
      break;
  case 'yahoo':
      window.location.href = "http://www.yahoo.com";
      break;
  
  }
  </code></pre>
  
  <p><strong>Method 3</strong></p>
  
  <pre><code>var hrefMap = {
  camelCase : "http://www.thecamelcase.com",
  jsFiddle: "http://www.jsfiddle.net",
  cricInfo: "http://www.cricinfo.com",
  apple: "http://www.apple.com",
  yahoo: "http://www.yahoo.com"
  };
  window.location.href = hrefMap[id];
  </code></pre>
  
  <p><strong>Method 4</strong></p>
  
  <pre><code>window.location.href = {
      camelCase : "http://www.thecamelcase.com",
      jsFiddle: "http://www.jsfiddle.net",
      cricInfo: "http://www.cricinfo.com",
      apple: "http://www.apple.com",
      yahoo: "http://www.yahoo.com"
  }[id];
  </code></pre>
  
  <p>Probably Method 3 and 4 might have almost the same performance but just posting to confirm.</p>