DEV Community

Discussion on: How to convert objects into arrays in Javascript

Collapse
 
rsa profile image
Ranieri Althoff

Very nice, I use these a lot since I learned about it.

Object.fromEntries is pretty useful. I use it in place of [...].reduce((prev, [key, value]) => ({ ...prev, [key]: value }), {}) for much cleaner syntax and better Typescript inference :D

Collapse
 
arikaturika profile image
Arika O

Funny, just yesterday I flattened an array using reduce() and I ran into Typescript issues because of the inference. Still didn't find a solution :D. But yes, these methods are super useful.