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
https://caniuse./#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./#search=find correct when says IE11 doesn't support Array.prototype.find ? Any evidence?
Thank you.
UPD: here is the screen of my IE11:
Share Improve this question edited Mar 13, 2019 at 9:47 Haradzieniec asked Mar 13, 2019 at 9:34 HaradzieniecHaradzieniec 9,34833 gold badges122 silver badges227 bronze badges 2- 1 You're running this in the context of SO? Well, SO may have defined that method using a polyfill… Try this again on an "empty" page! – deceze ♦ Commented Mar 13, 2019 at 9:49
- 1 No, it's from another website. The SO background is just another (but not third) window. That might be a reason to find if it that method was defined on the website where I do tests. I will let you know. And yes - I see in the Run code snippet in the SO it causes an error in IE11. – Haradzieniec Commented Mar 13, 2019 at 9:52
2 Answers
Reset to default 6Everything you have read is correct. There is something flawed about your tests. Perhaps you included a Polyfill that added the method in IE11.
You can try following steps to validate:
- Open a blank tab in IE.
- Open console in dev tools.
- 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: