Haradzieniec
Haradzieniec

Reputation: 9338

Array.prototype.find() vs IE11

https://caniuse.com/#search=find states The find() method is not supported by IE11.

At the same time I'm testing this find() method in IE11 and I didn't find any traces of any wrong behavior.

I've also tested in IE11 the code

function isPrime(element, index, array) {
  var start = 2;
  while (start <= Math.sqrt(element)) {
    if (element % start++ < 1) return false;
  }
  return (element > 1);
}

console.log([4, 5, 8, 12].find(isPrime)); // 5

from SO: Array.prototype.find() is undefined

Yes, in IE11 it returns the expected result of 5 instead of TypeError: undefined is not a function, as SO: Array.prototype.find() is undefined in 2014 stated.

So... Am I missing something and IE11 really doesn't work properly with Array.prototype.find , or the last updates of IE11 that were made a while ago (but later than the SO question above was discussed in 2014) became to support this method?

Is https://caniuse.com/#search=find correct when says IE11 doesn't support Array.prototype.find ? Any evidence?

Thank you.

UPD: here is the screen of my IE11: enter image description here

Upvotes: 2

Views: 2326

Answers (2)

Rajesh
Rajesh

Reputation: 24945

You can try following steps to validate:

  1. Open a blank tab in IE.
  2. Open console in dev tools.
  3. Enter following code: [1,2,3].find(function(n) { !!n; })
    • If above code throws error (which it should), you are using a polyfill. Hence your code does not break.
    • If it works, only explanation is that somehow, some update has added its definition. But this is very unlikely as MS has stopped support for it.

This is what I get:

enter image description here

Upvotes: 3

Quentin
Quentin

Reputation: 944203

Everything you have read is correct. There is something flawed about your tests. Perhaps you included a Polyfill that added the method in IE11.

It does not work in IE11

Upvotes: 6

Related Questions