How does .index work when I use it on the .exec() result in Javascript?
<p>I'm working on a program that extract information from a large chuck of text using javascript and while looking at a former co-workers code of something similar I found that when you save the result of .exec() and do .index of that variable it gives you the index of that substring in the array.</p>

<pre><code>Example:

var str="I found this for you!";
var pattern=/this/igm;
var result=pattern.exec(str);
document.write("\"This\" Index = " +  result.index + ".");

Result:

"This" Index = 8.
</code></pre>

<p>When I looked online I found that exec() returns an array and I looked at arrays I don't see .index being a property. All my searches of .index seem to come up index().</p>

<p>So basically my question is what is going on here? Why does this work? I'm also wondering if there are some other things I can do related to this (like .lastindex). Can anyone explain this to me or point me in the right direction (some keywords to google)?</p>
