Syntax Error only in IE

2019-07-25 13:54发布

I get a syntax error only in IE11 on this line and i can't seem to pinpoint what the issue is. Its on line two quizOptions.map((item, i) => {

the error is: SCRIPT1002: Syntax Error (this was the edit)

I haven't seen any issues with this piece of code on any other browser.

var quizOptions = cur_quizInfo.options;
quizOptions.map((item, i) => {
  var li = jQuery("<li>", {
    class: 'quiz_answers',
    text: item
  }).appendTo(buttonList);
});

1条回答
Luminary・发光体
2楼-- · 2019-07-25 14:30

ES6 arrow functions are not supported by Internet Explorer.

You could (probably) replace your example with this:

var quizOptions = cur_quizInfo.options;
quizOptions.map(function(item, i) {
  var li = jQuery("<li>", {
    class: 'quiz_answers',
    text: item
  }).appendTo(buttonList);
});
查看更多
登录 后发表回答