admin管理员组

文章数量:1399944

I have rather plex code that is executing a multiple AJAX call in sequence through the 'for' loop. This code works because I use 'Let' statement when assigning scope to a loop index. (let i = 0; i < 2; i++) { }.

However, 'Let' is giving me " Expected ';' error in Internet Explorer 11, While the code is working perfectly in other browsers. I have tried to move "let" out of the loop but it still fails, it seem to fail wherever the statement is used regardless of the loop. Please let me know what is the workaround for this as IE 11 is supposed to be patible with 'Let' statement.

I have rather plex code that is executing a multiple AJAX call in sequence through the 'for' loop. This code works because I use 'Let' statement when assigning scope to a loop index. (let i = 0; i < 2; i++) { }.

However, 'Let' is giving me " Expected ';' error in Internet Explorer 11, While the code is working perfectly in other browsers. I have tried to move "let" out of the loop but it still fails, it seem to fail wherever the statement is used regardless of the loop. Please let me know what is the workaround for this as IE 11 is supposed to be patible with 'Let' statement.

Share Improve this question asked Mar 4, 2019 at 18:55 Nemanja SovicNemanja Sovic 511 silver badge8 bronze badges 3
  • Are you sure your page isn't running in a patibility mode? – Pointy Commented Mar 4, 2019 at 18:57
  • 1 IE11 knows let but it works like var. – Teemu Commented Mar 4, 2019 at 18:57
  • Read note 5 here: caniuse./#feat=let – Randy Casburn Commented Mar 4, 2019 at 18:57
Add a ment  | 

1 Answer 1

Reset to default 7

See this ES6 support table. Internet Explorer 11 does not support let in for/for-in loop iteration scope.

You need to take a different approach.

This answer lists a number of options you could implement manually.

You could also use a tool like Babel to transpile your ES6 or newer JavaScript into ES5.

本文标签: Internet Explorer 11 JavaScript Let StatementStack Overflow