title: Get value by key from array javascript
body: <p>I'm experiencing an issue with getting the value from a javascript array.</p>
  
  <pre><code>var color = new Array();
  for (var i = 0; i &lt; datafeatures.length - 1; i++) {
      color[datafeatures[i].properties.userid] = datafeatures[i].properties.linecolor;
  }
  
  snapshot.forEach(function (childSnapshot) {
       var colour = childSnapshot.wp_user;
       console.log(color[colour]);
       console.log(JSON.stringify(color));
       console.log(color);
       console.log(colour);
  }
  </code></pre>
  
  <p>Console.log result: </p>
  
  <p><strong>color[colour]:</strong> undefined</p>
  
  <p><strong>JSON.stringify(color):</strong> []</p>
  
  <p><strong>color:</strong> </p>
  
  <pre><code>[]
   26: "#9d36ee"
   45: "#b1c743"
   56: "#f9c53c"
   61: "#d770ce"
   63: "#267fa1"
   64: "#85002f"
   68: "#78eca8"
   92: "#a4a2e7"
  length: 93
  __proto__: Array(0)
  </code></pre>
  
  <p><strong>colour:</strong> 61</p>
  
  <p>Expected output from color[colour]: "#d770ce"</p>
  
  <p>Real output from color[colour]: undefined.</p>
  
  <p>Color has something in it, Colour is a number (key), but it seems impossible to get a value from Color..</p>