title: Clearing URL hash
body: <p>Visit <code>stackoverflow.com/#_=_</code> and <code>window.location.hash</code> evaluates to <code>#_=_</code>. Fine.</p>
  
  <p>Now execute <code>window.location.hash = ''</code> to clear the hash, and the URL becomes <code>stackoverflow.com/#</code>. (Notice the trailing <code>#</code>.)</p>
  
  <p>Why is the <code>#</code> in <code>window.location.hash</code> inconsistently included or excluded? How can the <code>#</code> be removed from the URL without reloading the page?</p>
  
  <p>(<a href="https://developer.mozilla.org/en-US/docs/DOM/window.location">MDN</a> says</p>
  
  <blockquote>
    <p>[the hash is] the part of the URL that follows the # symbol, including the # symbol.</p>
  </blockquote>
  
  <p>but that is not true for in the case of an empty hash.)</p>