1

Hi is there any way to use a dynamic value in .map() of javascript function which is coming from outside?

Example:

data.map(item=> item."dynamic");

How to do this? or is it possible at all? I want to do this because, I want to use this map not for a single value like item.name but dynamically.

Jens
  • 5,767
  • 5
  • 54
  • 69
Ozzie
  • 475
  • 1
  • 5
  • 20

1 Answers1

3

Try with square ([]) bracket that allows dynamic property:

data.map(item=> item[dynamic])
Mamun
  • 66,969
  • 9
  • 47
  • 59