0
var jsonUiid = "sdfsdf";
a={
        [jsonUiid] : {
        "heading":"title"
        }
};

Tried directly in developer tools. The above code works in all browsers. It fails in Internet Explorer. Please help.

If we don't square bracket[], it directly gets "jsonUiid" rather than the actual value defined above.

Felix Kling
  • 756,363
  • 169
  • 1,062
  • 1,111
vsnu
  • 27
  • 6

1 Answers1

1

Computed property names are part of ES6 which is currently not fully supported by all browsers. You can set object property with old-style bracket notation:

var jsonUiid = "sdfsdf";
var a = {};
a[jsonUiid] = {
    "heading": "title"
};
madox2
  • 45,325
  • 15
  • 94
  • 95