title: Why does string.match(...)[0] throws an exception?
body: <p>I'm trying to pull the first occurence of a regex pattern from a string all in one statement to make my code look cleaner. This is what I want to do:</p>
  
  <pre><code>var matchedString = somestring.match(/some regex/g)[0];
  </code></pre>
  
  <p>I would expect this to be legal but it throws an exception: </p>
  
  <pre><code>Exception: somestring.match(...) is null
  </code></pre>
  
  <p>It seems like JS is trying to index the array before match is finsihed, as the array does provide atleast one match, so I don't expect it to be null.</p>
  
  <p>I would like some insight in why it happens. Could it be a bug? </p>
  
  <p>My machine is a PC running Arch Linux x86_64. The code is being executed within the scratchpad of firefox 32.0.3.</p>
  
  <p>Thanks for your interest.</p>