1

I have the following for loop in JS and it works in all browsers but I am getting an "Expected ; " error in IE11 for the for loop line. Do I have to change format to make it play nice?

for (var filter of filters) { 
   //do something
  }
2
  • 2
    Scroll down to the compatibility section: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Commented Oct 5, 2018 at 17:42
  • 2
    Is it a for in loop like in the title of your question or a for of loop like in the code you posted? And is it IE11 or IE8? Commented Oct 5, 2018 at 17:43

1 Answer 1

1

for...of is an ES6 feature and therefore unsupported in IE. You need to either translate this to an ordinary for loop, or transpile your code before running it in an old browser like IE.

Sign up to request clarification or add additional context in comments.

5 Comments

The alternative answer: don't use an outdated browser like IE, but use Edge instead.
While I'd be delighted to see the back of IE, an inordinate number of users seem to still use it, and it's best to keep everyone happy if it's not too much effort.
trust me lol i wish my customers didnt use IE, its like impossible to download these days idk why people still use it.
anyways is for in support in IE? just not for of?
Yes, for...in is fine in IE, apparently even back to IE6 developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… But it's a poor way to loop through an array, a regular for loop is almost always better.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.