DEV Community

Discussion on: A Quick JS Reduction: My possibly-too-clever way to reduce an array into one object in javascript

Collapse
 
avalander profile image
Avalander

Not that it matters, but for the sake of offering an alternative solution I'd probably lean more towards Object.fromEntries than reduce.

Object.fromEntries(users.map(u => [ u.id, u ]))
Enter fullscreen mode Exit fullscreen mode
Collapse
 
brettimus profile image
Boots

totally matters and I wish I could heart this twice -- I've never seen Object.fromEntries!