Home > Net >  Avoid using Object.values
Avoid using Object.values

Time:01-16

df is an array of objects

I want to simplify this code, maybe the usage of Object.values could be redundant if I use another thing than map

Object.values(df.map(o => o.prop))

This piece of code returns an array of props.

Is it possible?

CodePudding user response:

Unless df is a sparse array, the Object.values is totally redundant indeed.

df.map(o => o.prop)

already returns the same value as

Object.values(df.map(o => o.prop))
  • Related