title: Check if string begins with something?
body: <p>I know that I can do like <code>^=</code> to see if an id starts with something, and I tried using that for this, but it didn't work. Basically, I'm retrieving a URL and I want to set a class for an element for path names that start in a certain way.</p>
  <p>Example:</p>
  <pre><code>var pathname = window.location.pathname;  //gives me /sub/1/train/yonks/459087
  </code></pre>
  <p>I want to make sure that for every path that starts with <code>/sub/1</code>, I can set a class for an element:</p>
  <pre><code>if (pathname ^= '/sub/1') {  //this didn't work... 
          ... 
  </code></pre>