Get all unique object properties from array of objects Get all unique object properties from array of objects angularjs angularjs

Get all unique object properties from array of objects


A solution using only:

var data = [{  "firstName": "John",  "lastName": "Doe"}, {  "firstName": "Anna",  "car": true}, {  "firstName": "Peter",  "lastName": "Jones"}];var uniqueKeys = Object.keys(data.reduce(function(result, obj) {  return Object.assign(result, obj);}, {}))console.log(uniqueKeys);