title: Getting all the values for a given key, in an array of objects, using JavaScript and/or D3.js
body: <p>I'm building a dashboard that uses D3.js for charts.  I have a large array of objects.  Each object has 32 key value pairs, with the same keys.  Doesn't anyone know a good way to get all the values for a given key?</p>
  
  <p>EDIT:
  As soon as I asked the question a simple function came to me.  Also thought maybe a function already existed that I wasn't finding.</p>
  
  <pre><code>function getValues(data, key){
    var values = [];
  
    data.forEach(function(d){
      var v = d[key];
  
      if(!d3.set(values).has(v)){
        values.push(v);
      }
    })
  
    return values;
  }
  </code></pre>