Array push not working in IE5 using javascript?
<p>When I try to load the select options into the <strong>optStored</strong> array using the array push, the array always remains empty. In chrome, firefox, and safari the code is working correctly but not in Internet Explorer. Is there a work around for this or nothing can be done about this?</p>

<blockquote>
  <p><strong>Updated 2:12am 10/11/16:</strong> Made some changes to the code, previous code is commented out but the array still remains empty! Is there a solution?</p>
</blockquote>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// array to store select options
var optStored = [];

// filter select 
function filterFruits(el) {
  var value = el.value.toLowerCase();
  var form = el.form;
  var opt, sel = form.fruits;
  if (value == "") {
    restoreOpts();
  } else {
    for (var i = sel.options.length - 1; i &gt;= 0; i--) {
      opt = sel.options[i];
      if (opt.text.toLowerCase().indexOf(value) == -1) {
        sel.removeChild(opt);
      }
    }
  }
}

// Restore select options
function restoreOpts() {
  var sel = document.getElementById('fruits');
  sel.options.length = 0;
  for (var i = 0, iLen = optStored.length; i &lt; iLen; i++) {
    // Recent Update 2:12am 10/11/16:
    // Found aworkaround for restoring the select options 
    // This method works with versions of IE4+
    sel.options[sel.options.length] = new Option(optStored[i].text, optStored[i].value, false, false);

    // Recent Comment Update 2:12am 10/11/16: 
    // Console complains of a type mismatch error
    // sel.add(optStored[i], null); 
  }
}

// Load select options
window.onload = function() {
  var sel = document.getElementById('fruits');
  for (var i = 0, iLen = sel.options.length; i &lt; iLen; i++) {
    // Recent Comment Update 2:12am 10/11/16: 
    // tried this method as well but no luck. 
    // it was also mentioned in the comments below
    // the array still remains empty!
    optStored[i] = sel.options[i];

    //optStored.push(sel.options[i]);
  }
};</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
  &lt;input type="text" onkeyup="filterFruits(this);" placeholder="Filter"&gt;
  &lt;select id="fruits"&gt;
    &lt;option value="1"&gt;Apple&lt;/option&gt;
    &lt;option value="2"&gt;Orange&lt;/option&gt;
    &lt;option value="3"&gt;Cherry&lt;/option&gt;
    &lt;option value="4"&gt;Banana&lt;/option&gt;
  &lt;/select&gt;
&lt;/form&gt;</code></pre>
</div>
</div>
</p>