Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which web browsers natively support Array.forEach()

Which browsers other than Firefox support Array.forEach()? Mozilla say it's an extension to the standard and I realise it's trivial to add to the array prototype, I'm just wondering what other browsers support it?

like image 247
slashnick Avatar asked Oct 01 '08 08:10

slashnick


People also ask

Does IE11 support forEach?

We have identify a bug. We think. In IE11 the Nodelist object (return by the querySelectorAll) has not the forEach method directly accessible.

Where can I use forEach?

forEach is an Array method that we can use to execute a function on each element in an array. It can only be used on Arrays, Maps, and Sets. When using forEach , we simply have to specify a callback function. This callback will be executed on each element in the array.

Does JavaScript support forEach loop?

The JavaScript forEach method is one of the several ways to loop through arrays. Each method has different features, and it is up to you, depending on what you're doing, to decide which one to use.

Is forEach blocking in JavaScript?

forEach Asynchronous? It is not asynchronous. It is blocking. Those who first learned a language like Java, C, or Python before they try JS will get confused when they try to put an arbitrary delay or an API call in their loop body.


1 Answers

I just checked this for another question: JavaScript for...in vs for.

On kangax's ECMAScript 5 compatibility table, Array.forEach gets a 'yes' for all browsers except IE8.

As of September 2011, IE browser share on desktop devices is less than 40%, and at least 8% of browsers are IE 9.

In other words, Array.forEach is now supported by around 70% of desktop browsers. Obviously, this figure varies considerably, depending on territory and other factors -- some regions or countries (such as Brasil) have a higher proportion of Chrome users, for example, and some (such as China) have far more users on IE6 and IE8.

I haven't checked, but mobile support (on WebKit and Opera browsers) may be even higher.

like image 163
Sam Dutton Avatar answered Sep 23 '22 12:09

Sam Dutton