title: Check Length of Multidimensional Arrays with Javascript
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5223/length-of-javascript-associative-array">Length of Javascript Associative Array</a>  </p>
  </blockquote>
  
  
  
  <p>I want to check the length of a multidimensional array but I get "undefined" as the return. I'm assuming that I am doing something wrong with my code but I can't see anything odd about it.</p>
  
  <pre><code>alert(patientsData.length); //undefined
  alert(patientsData["XXXXX"].length); //undefined
  alert(patientsData["XXXXX"]['firstName']); //a name
  
  fruits = ["Banana", "Orange", "Apple", "Mango"];
  alert(fruits.length); //4
  </code></pre>
  
  <p>Thoughts? Could this have something to do with scope? The array is declared and set outside of the function. Could this have something to do with JSON? I created the array from an eval() statement. Why does the dummy array work just fine?</p>