title: Why can I add named properties to an array as if it were an object?
body: <p>The following two different code snippets seem equivalent to me:</p>
  
  <pre><code>var myArray = Array();
  myArray['A'] = "Athens";
  myArray['B'] = "Berlin";
  </code></pre>
  
  <p>and</p>
  
  <pre><code>var myObject = {'A': 'Athens', 'B':'Berlin'};
  </code></pre>
  
  <p>because they both behave the same, and also <code>typeof(myArray) == typeof(myObjects)</code> (both yield 'object').</p>
  
  <p><strong>Is there any difference between these variants?</strong></p>