title: TypeScript: Get cookie located on any path
body: <p>I'd like to get a cookie localted on any path. Currently, I'm getting cookies value using this code:</p>
  
  <pre><code>export function getCookie(name) {
    let match = document.cookie.match(new RegExp(name + '=([^;]+)'));
    return match ? match[1] : undefined;
  }
  </code></pre>
  
  <p>I don't quite figure out how this code is looking up on cookies.</p>
  
  <p>Any ideas?</p>