title: Distinguish between array and hash in javascript with typeof()
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/218798/in-javascript-how-can-we-identify-whether-an-object-is-a-hash-or-an-array">In javascript how can we identify whether an object is a Hash or an Array?</a>  </p>
  </blockquote>
  
  
  
  <p>In javascript</p>
  
  <pre><code>typeof([])
  </code></pre>
  
  <p>and </p>
  
  <pre><code>typeof({})
  </code></pre>
  
  <p>both return "object".</p>
  
  <p>How can I reliably distinguish between an array and an associative array in Javascript?</p>
  
  <p>I have thought of testing the object in question to see if it has the "length" attribute (indicating it would be an array), but what then the following would also be seen as an array:</p>
  
  <pre><code>{length:5}
  </code></pre>