Is object[0] sort of a default key for an object in JavaScript?
<p>Here's a small JavaScript snippet:</p>

<pre><code>  var re_words = /\w+/g;

  var words;
  while (words = re_words.exec(' here are a few (sic!) words ')) {
     alert(words);
  }
</code></pre>

<p>The loop alerts the words found in the input string, which is what I expected, because all the JavaScript tutorials tell me so.</p>

<p>Now, <strong>typeof(words)</strong> results in <strong>object</strong>.</p>

<p>Therefore, I would have expected <strong>alert(words)</strong> to give me <strong>object</strong>.</p>

<p>If I inspect the elements in words, I found them to be 0, "index" and "input". The element words[0] is the same as what is alerted with words.</p>

<p>So, the question is: is the element 0 sort of a default index for an Object in JavaScript which is returned if it is defined. </p>

<p>Or asked differently: why does <strong>alert(words)</strong> give the same effect as <strong>alert(words[0])</strong>? I would have expected alert(words) to give a "Object".</p>
