title: Getting the values for a specific key from all objects in an array
body: <p>I'm running an express.js app that has a few apis feeding data to dropdown boxes. The data returned is in the form:</p>
  
  <pre><code>  [
      {
          key: 'blah',
          value: 'Blah Blah'
      },
      {
          key: 'foo',
          value: 'Foos'
      },
      {
          key: 'bar',
          value: 'Bars'
      },
      {
          key: 'baz',
          value: 'Bazingo'
      }
  ];
  </code></pre>
  
  <p>where key is my option key and value is the display text. The structure of this array is fixed and I know for a fact that I'll always have key and value as the fields in each object in the array. </p>
  
  <p>When I try to validate the form submitted (additional server side validation), I'd like to cross-reference the value provided for a field against all the values for "key" in the array (blah, foo, bar, baz). Given that this is going to be a frequently used route, I'd like to avoid iterating over the array to find the permitted values, every single time. Is there a simpler way to do this? In other words, I know I can use:</p>
  
  <pre><code> permittedValues = [];
   for (i = 0; i &lt; array.length; i++){
      permittedValues[i] = array[i]["key"];
   }
  </code></pre>
  
  <p>but I'd like to avoid this for loop, if possible.</p>
  
  <p>P.S: This seems to be a fundamental question and the answers I found online didn't exactly answer my question. So, apologies if this has already been asked and answered.</p>