title: Determine domain name in JavaScript?
body: <p>What's the difference between using</p>
  
  <pre><code>if (document.domain.toLowerCase().indexOf("domainName") != -1)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(window.location.href.match(/:\/\/(.[^/]+)/)[1].toLowerCase().indexOf("domainName") != -1)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(window.location.hostname.toLowerCase().indexOf("domainName") != -1)
  </code></pre>
  
  <p>I'm just trying to match on a certain domainName and want to use the best approach.</p>