0

Needing to do:

var some = {
    `${foo1}_${foo2}`: bar
}

but this gives a syntax error though I must do it somehow. How?

xendi
  • 2,054
  • 4
  • 32
  • 59

1 Answers1

0

you can suppose object as hashmap and access properties via []

var foo1 = 'a';
var foo2 = 'b';
var some = {};
some[foo1+'_'+foo2] = 'test';

console.log(some.a_b);
Iłya Bursov
  • 21,884
  • 4
  • 31
  • 54