DEV Community

[Comment from a deleted post]
Collapse
 
jwkicklighter profile image
Jordan Kicklighter

I use Object.keys frequently, but I always forget about Object.entries!

Collapse
 
jasperdiongco profile image
Jasper Diongco • Edited

In my opinion, Object.keys is much simpler than Object.entries

Collapse
 
jwkicklighter profile image
Jordan Kicklighter • Edited

I'm not sure that's always the case (although like you said, it's just opinion). If the goal is to iterate over the values, then

Object.entries(arr).map(x => x)

feels more concise than

Object.keys(arr).map(x => arr[x])