Object.entries(data.reduce((acc, curr) => {
for (let key in curr) {
acc[key] = acc[key] || {values: [curr[key]], count: 0};
if (acc[key].values.includes(curr[key])) {
acc[key].count++;
} else {
acc[key].values.push(curr[key]);
}
}
return acc;
}, {})).reduce((acc, [key, {count}]) => ((acc[key] = count), acc), {});
или так
data.reduce((acc, curr) => {
for (let key in curr) {
let item = acc.find((item) => item.key === key);
if (!item) {
item = {key, values: [curr[key]], count: 0};
acc.push(item);
}
if (item.values.includes(curr[key])) {
item.count++;
} else {
item.values.push(curr[key]);
}
}
return acc;
}, []).reduce((acc, {key, count}) => ((acc[key] = count), acc), {});