JSFiddle - React, Tailwind, and code Playground
HTML
<div id="result">Property without unique entries:</div>
JavaScript
Array.prototype.allValuesSame = function() {
for(var i = 1; i < this.length; i++) {
if(this[i] !== this[0])
return false;
}
return true;
}
var data = [
{Date: "2016-04-27T09:03:45Z", Name: "Tito", Title: "Developer", Department:"IT", Company: "XXX"},
{Date: "2016-04-27T08:07:45Z", Name: "Tito", Title: "Developer", Department:"IT", Company: "XXX"},
{Date: "2016-04-27T10:23:45Z", Name: "Tito", Title: "Developer", Department:"IT", Company: "XXX"}
]
var tmpPropValues = {};
for (var property in data[0]) {
tmpPropValues[property] = [];
for(var i = 0; i < data.length; i++) {
var obj = data[i];
// store temporary in array
if (obj.hasOwnProperty(property)) {
var value = obj[property];
tmpPropValues[property].push(value);
}
}
if(tmpPropValues[property].allValuesSame()) {
delete tmpPropValues[property];
}
}
for(var prop in tmpPropValues) {
var tmp = document.getElementById("result").innerHTML;
document.getElementById("result").innerHTML = tmp+" "+prop;
}