最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

semicolon error in javascript for loop in internet explorer 10 and lower version of ie - Stack Overflow

programmeradmin6浏览0评论

Hello everyone I have an issue related Internet Explorer 10 and older version,

my code is running properly in all the browser

(Chrome, Firefox, Internet Explorer 11)

but when i tried to run that in Internet Explorer 10 and 9 I am getting the error of

SCRIPT1004: Expected ';'google.map.js (1270,14)

and on that particular line i have a for loop

for (let i = 0; i < Markers.length; i++) {

and my full function

function clearMarker() {
    for (let i = 0; i < Markers.length; i++) {
        Markers[i].setMap(null);
    }
    Markers = new Array();
}

i don't understand why this error is ing in my console. and this is working fine in other browsers,

is it related to patibility of ie 10 and lesser?

Hello everyone I have an issue related Internet Explorer 10 and older version,

my code is running properly in all the browser

(Chrome, Firefox, Internet Explorer 11)

but when i tried to run that in Internet Explorer 10 and 9 I am getting the error of

SCRIPT1004: Expected ';'google.map.js (1270,14)

and on that particular line i have a for loop

for (let i = 0; i < Markers.length; i++) {

and my full function

function clearMarker() {
    for (let i = 0; i < Markers.length; i++) {
        Markers[i].setMap(null);
    }
    Markers = new Array();
}

i don't understand why this error is ing in my console. and this is working fine in other browsers,

is it related to patibility of ie 10 and lesser?

Share Improve this question edited Jan 2, 2019 at 5:48 asked Jun 29, 2018 at 6:45 user6656728user6656728 6
  • 8 let is not supported in IE10. In IEs it was first introduced in IE11, but didn't create a block scope. – Teemu Commented Jun 29, 2018 at 6:45
  • 2 Change from let to var ... for (var i = 0; i < Markers.length; i++) { – Asons Commented Jun 29, 2018 at 6:46
  • Are you working on a node environment or writing code directly in the html/js files? – Aseem Upadhyay Commented Jun 29, 2018 at 6:51
  • You can check browser support here. caniuse./#search=let . As you can see from the URL, IE 11 is the lowest version partially supporting let. So you should use var instead. – Lewis Commented Jun 29, 2018 at 6:52
  • I am working on jquery with mvc @AseemUpadhyay – user6656728 Commented Jun 29, 2018 at 6:57
 |  Show 1 more ment

1 Answer 1

Reset to default 9

let and const are not valid in IE 10 or below and worse yet they don't work right in IE 11! You shouldn't use them. You should change the let to a var.

You can find more information at Can I use about what browsers will support it or the MDN article on let

发布评论

评论列表(0)

  1. 暂无评论