convert array to dictionary javascript Code Example

PHOTO EMBED

Tue Nov 16 2021 15:04:46 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol

let dictionary = Object.assign({}, ...data.map((x) => ({[x.id]: x.country})));
content_copyCOPY

https://www.codegrepper.com/code-examples/javascript/convert+array+to+dictionary+javascript