title: array[oListItem.id] has values but array[6], array[7] etc. are undefined
body: <p>I retrieve values from a SharePoint list and put them in an array <code>itemprices</code>.</p>
  
  <p>Using <code>console.log("Price of list item at is:" + itemprices[oListItem.id]);</code> will print out the values of the array, but using <code>console.log("itemprices 5: " + itemprices[5]);</code> tells me that they are undefined:</p>
  
  <p><a href="https://i.stack.imgur.com/i6jGP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i6jGP.png" alt="undefined"></a></p>
  
  <p>This is the code I used:</p>
  
  <pre><code>var itemprices = [];
  
  // Gets values from Catalogue list; but they can't be used in the Position list because of different formats
  function retrieveListItems() {
      var clientContext = new SP.ClientContext.get_current();
      catalogueList = clientContext.get_web().get_lists().getByTitle('Catalog');
  
      var camlQuery = new SP.CamlQuery(); // initiate the query object
      camlQuery.set_viewXml('&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;In&gt;&lt;FieldRef Name=\'ID\'/&gt;&lt;Values&gt;&lt;Value Type=\'Number\'&gt;5&lt;/Value&gt;&lt;Value Type=\'Number\'&gt;6&lt;/Value&gt;&lt;Value Type=\'Number\'&gt;7&lt;/Value&gt;&lt;/Values&gt;&lt;/In&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;');
      itemColl = catalogueList.getItems(camlQuery);
  
      // returns the item collection based on the query
      context.load(itemColl);
      context.executeQueryAsync(retrieveListItemsSuccess, retrieveListItemsFail);
  }
  
  function retrieveListItemsSuccess() {
      var listItemEnumerator = itemColl.getEnumerator();
      while (listItemEnumerator.moveNext()) {
          var oListItem = listItemEnumerator.get_current();
          itemprices[oListItem.id] = oListItem.get_item('Preis');
          console.log("itemprices 5: " + itemprices[5]);
          console.log("itemprices 6: " + itemprices[6]);
          console.log("itemprices 7: " + itemprices[7]);
          console.log("Price of list item at is:" + itemprices[oListItem.id]);
      }
  }
  // This function is executed if the above call fails
  function retrieveListItemsFail(sender, args) {
      alert('Failed to get list items. Error:' + args.get_message());
  }
  </code></pre>
  
  <p>I don't know if this is a JavaScript issue or a SharePoint issue. What am I doing wrong?</p>