2

from many articles I have chosen this syntax to make unique values in an array.

pairs = pre_final_pairs.filter((elem, index) =>  pre_final_pairs.indexOf(elem) === index).join(' ');

This works perfectly in all browsers except Internet Explorer 11.

I have tried to find which of the command from the line is not compatible and I found that maybe the indexOf. But even if I tried to apply "fix" referred in How to fix Array indexOf() in JavaScript for Internet Explorer browsers still the page is not working in the IE11.

Also I have loaded https://code.google.com/archive/p/ddr-ecma5/ library in order to ensure that the ECMA commands will work.

And still getting SCRIPT1002: Syntax error

Do you see there a wrong part in the command?

Community
  • 1
  • 1
Reddy SK
  • 1,334
  • 4
  • 19
  • 27

1 Answers1

4

Internet Explorer does support indexOf, but does not support arrow functions.

You can easily fix that using a regular function for the callback instead:

pairs = pre_final_pairs.filter(
    function (elem, index) {
        return pre_final_pairs.indexOf(elem) === index;
    }
).join(' ');
GOTO 0
  • 42,323
  • 22
  • 125
  • 158