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,427
  • 1
  • 14
  • 20
Damkulul
  • 1,406
  • 2
  • 25
  • 59

0 Answers0