How can I loop through this array in javascript?
<p>I'm trying to loop through this array but it does not return any length. Is it possible?</p>

<p>Thanks!</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;body&gt;
    &lt;button onclick="myFunction()"&gt;click&lt;/button&gt;
    &lt;script&gt;
      function myFunction()
      {
        var fruits = [];
        fruits["B"] = "Banana";
        fruits["A"] = "Apple";
        fruits["O"] = "Orange";

        delete fruits["A"];

        alert(fruits["A"]); // Alerts "undefined"
        alert(fruits["B"]); // Alerts "Banana"
        alert(fruits.length); // Alerts "0"
      }
    &lt;/script&gt;

  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
