Created
August 9, 2019 11:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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