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});
   });
3
  • 1
    Does this answer your question? Dynamically create object keys in IE 11 (Expected identifier, string or number, not a comma issue) Commented Mar 24, 2020 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? Commented Mar 24, 2020 at 22:04
  • Remember, you can always blame Microsoft. Commented Mar 24, 2020 at 22:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.