0

I'm trying to create a javascript object with a property that's a declared string:

var theTitle = 'Hello';
helloWorld = {theTitle : 'World'};

Will output 'theTitle' as the property name..

So I tried:

var theTitle = 'Hello';
helloWorld = {[theTitle] : 'World'};

Works well, but not on Safari..

What's the way to do this??

sigmaxf
  • 7,998
  • 15
  • 65
  • 125

0 Answers0