Behold, I possess an intricate object structured as follows:
sum = {
value:{
a: 10,
b: 11
}
value2:{
a: 33,
c: 12
}
..
}
Delving deeper into the complexity of my object reveals that each letter harbors unique objects with varying values. Yet, the ultimate goal is to traverse through all letters present in each value and generate outcomes akin to the following:
a:{
value: 10,
value2: 33
}
The conventional method would involve iterating through the entire structure to construct a new object. However, is there a more streamlined approach to essentially "flip" the order of objects?
Specifically, I seek to utilize solely the keys shared across all value-objects. While currently obtaining them like this, it remains non-essential:
value = ['value', 'value2']
tags.forEach( (tag) =>
keys.push(Object.keys(sum[tag]))
)
matches = _.intersection.apply(_, keys);
matches.forEach( (match) => {
...
}