Single value doesn't mean it can't be a collection type I think is the OP's point. For example you can use reduce to easily make a lookup map out of an array:
[ { id: 123, name: "Ben" }, { id: 456, name: "Sarah" }, { id: 789, name: "Jane" } ].reduce((acc, e) => { return { [e.id]: e.name, ...acc } }, {}) /* output- { 123: Ben, 456: Sarah, 789: Jane } */
Yes, thank you for a nice example.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Single value doesn't mean it can't be a collection type I think is the OP's point. For example you can use reduce to easily make a lookup map out of an array:
Yes, thank you for a nice example.