0

I'm having a problem with the incompatibility between Chrome/Firefox and Internet Explorer regards to using a variable as key in creating an array. Bellow it's my code. In IE11 I have the error: SCRIPT1028: Expected identifier, string or number.

What should I change in order to work in IE11? I tried several ways, but without success. Thank you.

var form_r = [];
 $(".form_tracing input[type=text]").each(function() {
    id_input = $(this).attr('id');
    values= $(this).val() != '' ? $(this).val() : "";
    form_r.push({ [id_input] : values});
   });
VLAZ
  • 26,331
  • 9
  • 49
  • 67
  • 1
    Does this answer your question? [Dynamically create object keys in IE 11 (Expected identifier, string or number, not a comma issue)](https://stackoverflow.com/questions/37392656/dynamically-create-object-keys-in-ie-11-expected-identifier-string-or-number) – VLAZ Mar 24 '20 at 21:56
  • Yes, it confirms my nightmare :( IE doesn't support the new "object literal extensions" from ES6 (ES2015). Thank you for your quick response. Now i have to write manually all array keys. Why IE? Why? – star0kitty Mar 24 '20 at 22:04
  • Remember, you can always blame Microsoft. – VLAZ Mar 24 '20 at 22:08

0 Answers0