Skip to content

Instantly share code, notes, and snippets.

@johncaruso
Created August 9, 2019 11:21
Show Gist options
  • Select an option

  • Save johncaruso/c3920b923a06f1f49d4cf39651a57623 to your computer and use it in GitHub Desktop.

Select an option

Save johncaruso/c3920b923a06f1f49d4cf39651a57623 to your computer and use it in GitHub Desktop.
Convert array of entity objects to object w/entity key, entity object pairs
function arrayToObject(array, keyField) {
return array.reduce(function(obj, item) {
obj[item[keyField]] = item;
return obj;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment