0

I am using an object in javascript and I need to get it's values by dynamic attributes, how do I use concatenation to get the right syntax ?

To make it clearer this is my code:

dataObj[0].xxxxxxxx.Value;(xxxxxxx -> dynamic)

I tried: set my attr name in a var :

var curr = "games" - > `dataObj[0].+curr+.Value;`    //- NO GOOD
use [] - > `dataObj[0].[curr].Value`                 //- NO GOOD
use +"+ - > `dataObj[0].+'"'+curr+'"'+.Value`        //- NO GOOD
wayneOS
  • 1,439
  • 1
  • 11
  • 19
Damkulul
  • 1,310
  • 1
  • 19
  • 53

0 Answers0