Flip key value pair on 1 lvl depth
问题 I have object: const pairs = { A: { D: [1, 2, 3] }, B: { D: [3, 2, 1] }, C: { D: [4, 3, 2, 1], B: [0, 1, 2, 3] } }; How can I get it fliped? const fliped = { D: { A: [1, 2, 3], B: [3, 2, 1], C: [4, 3, 2, 1] }, B: { C: [0, 1, 2, 3] } }; ES6 solution will be great I tried something like, but find that im not very good with reduce method and start thinkind about ugly imperative solution: Object.entries(pairs).reduce( (acc, [key1, value]) => Object.keys(value).reduce( (acc, key2) => ({ ...acc,