javasccript find element in array of object
<p>Let's say I have an array of objects and one of the properties of each object is TheID.
Something like this:</p>

<pre><code>TheArray[0].TheID = 34;
TheArray[1].TheID = 2352;
...
</code></pre>

<p>I'm looking to return the index of the array that contains the property TheID I'm looking for.</p>

<p>I have a classic for-loop:</p>

<pre><code>for (i = 0; i &lt; TheArray.length; i++) {
   if (TheArray[i].TheID = MagicNumber) { var TheIndex = i; } 
}
retun TheIndex;
</code></pre>

<p>This works but it still has to loop through the entire array, even after it found TheIndex.</p>

<p>How do you stop the loop after the it found TheIndex?</p>

<p>Thanks.</p>
