Extracting matched items from an object which has properties of arrays
Try this code:

function transformObject(data) {
  const values = Object.values(data);
  const keys = Object.keys(data);
  const transposed = values[0].map((col, i) =&gt; values.map(row =&gt; row[i]));
  return transposed.map(itemArr =&gt; keys.reduce((acc, key, i) =&gt; ({...acc, [key]: itemArr[i]}), {}));
}


The idea is to transpose the values 2D array and then map it using reduce for each row. The transposed array will look like:

[
  ["1", "foo", 20, "pluto"],
  ["2", "bar", 30, "mars"],
  ...
]


This piece of code keys.reduce((acc, key, i) =&gt; ({...acc, [key]: itemArr[i]}), {}) is simply zips two arrays: keys and the row from transposed array.



function transformObject(data) {
  const values = Object.values(data);
  const keys = Object.keys(data);
  const transposed = values[0].map((col, i) =&gt; values.map(row =&gt; row[i]));
  return transposed.map(itemArr =&gt; keys.reduce((acc, key, i) =&gt; ({...acc, [key]: itemArr[i]}), {}));
}

console.log(transformObject({
  "id": ["1", "2", "3"],
  "name": ["foo", "bar", "baz"],
  "age": [20, 30, 40 ],
  "location": ["pluto", "mars", "jupiter"],
}));