0

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,472
  • 5
  • 49
  • 68
Ozzie
  • 325
  • 1
  • 4
  • 16

1 Answers1

2

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

data.map(item=> item[dynamic])
Mamun
  • 62,450
  • 9
  • 45
  • 52