title: Get all unique object properties from array of objects
body: <p>Let's imagine I have an array of objects e.g.</p>
  
  <pre><code> [{
      "firstName": "John",
      "lastName": "Doe"
   }, {
      "firstName": "Anna",
      "car": true
   }, {
      "firstName": "Peter",
      "lastName": "Jones"
   }]
  </code></pre>
  
  <p>I want to get all the unique property names from this array of objects, so the result will be:</p>
  
  <pre><code>[firstName, lastName, car]
  </code></pre>
  
  <p><strong>How can I do it:</strong></p>
  
  <p>I can imagine that it's possible to do this with something like this:</p>
  
  <pre><code>function getPropertiesNames(obj){
    var arr = [];
    for(var name in obj) {
      if(arr.indexOf(name) != -1) arr.push(name);
    }
   return arr;
  } 
  </code></pre>
  
  <p><strong>Why I need it:</strong></p>
  
  <p>I will have to make a table of multiple objects. Because each object can be a bit different I need unique property names.  However I am going to do it in angularJS so it's kind of a bad option for me to once use loop to get property names for <code>&lt;th&gt;</code> and once again use loop with <code>&lt;tr ng-repeat&gt;&lt;/tr&gt;</code> to display values.</p>
  
  <p><strong>What i want:</strong></p>
  
  <p>Is there some option to get all unique property names from an array of objects without iterating it? Maybe some lodash or build in JS function which I don't know?</p>