2

I have two arrays

var master= ["1","2","3"];
var arr = ["1","5"];

i wanted to check if arr contains any item from master. Based on SO post here i have the following code which only works with chrome

var found = arr.some(r => master.indexOf(r) >= 0);

however it does not work with IE11. IE11 throws error

JavaScript critical error at line 23, column 44 in https://localhost:44328/js/xxxx.js\n\nSCRIPT1002: Syntax error

I have also tried

 var found = arr.some(r => master.includes(r) >= 0);
Nico Diz
  • 1,448
  • 1
  • 6
  • 19
LP13
  • 25,900
  • 45
  • 172
  • 339

1 Answers1

4

You need to take a classic function, because IE 11 has only ES5, that means no arrow functions nor Array#includes.

var master= ["1", "2", "3"],
    arr = ["1", "5"],
    found = arr.some(function (r) { return master.indexOf(r) >= 0; });

console.log(found);
Nina Scholz
  • 351,820
  • 24
  • 303
  • 358