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
  • 795,719
  • 175
  • 1,089
  • 1,143
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
  • 49,493
  • 17
  • 99
  • 99