Syntax Error only in IE

China☆狼群 提交于 2019-12-12 23:13:59

问题


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:


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);
});


来源:https://stackoverflow.com/questions/42149754/syntax-error-only-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!