Skip to content

Instantly share code, notes, and snippets.

@AntonisFK
Created February 13, 2018 17:18
Show Gist options
  • Save AntonisFK/56ac1b5043e96d600551a2bcea3f06cc to your computer and use it in GitHub Desktop.
Save AntonisFK/56ac1b5043e96d600551a2bcea3f06cc to your computer and use it in GitHub Desktop.
Reduce an array of objects to one object
const resultObject = resArr.reduce((result, currentObject) => {
for (const key in currentObject) {
if (currentObject.hasOwnProperty(key)) {
result[key] = currentObject[key];
}
}
return result;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment