Fast loop through Javascript array
<p>On my JSP page I have a select object that could contain 60k+ objects.  I am storing those 60k+ objects into a javascript Array called "masterList".  I have provided the user an input box to filter the list.  Filtering is based on a "begins with.." approach.  Is there a faster way to do this?  I am noticing performance issues when a user inputs zero or 1 character into the input box.</p>

<p>This is how my code looks now.</p>

<pre><code>    var numShown = 0;
    var listLength = masterList.length;     

    for(i = 0; i &lt; listLength; i++){
        if(masterList[i].search(re) != -1){
            selectBox[numShown] = new Option(masterList[i], masterList[i]);
            numShown++;
        }

        // Stop when the number to show is reached and input present
        if(input.value != "" &amp;&amp; numShown == maxToShow){
            break;
        }
    }
</code></pre>
