0

Needing to do:

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

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

xendi
  • 2,332
  • 5
  • 40
  • 64

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
  • 23,342
  • 4
  • 33
  • 57