41

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?

asked Oct 1, 2008 at 8:26

7 Answers 7

20

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.

answered Sep 13, 2011 at 11:38
Sign up to request clarification or add additional context in comments.

1 Comment

Which is still enough to be a problem in this day and age :-( go for jquery each instead.
12

The JavaScript article of Wikipedia lists the JS versions by browser. forEach is part of JavaScript 1.6. So it is supported indeed by most browsers, except Opera 9.02 (which I just tested). Opera 9.5 (which I just installed!) supports it, along with indexOf for Array.

Surprisingly, it is not official. I don't see its support in the page ECMAScript support in Opera 9.5. Perhaps it is an overlook or perhaps only a partial support they don't want to advertise.

answered Oct 1, 2008 at 9:04

1 Comment

Wikipedia doesn't list the versions anymore, and I can't find a full list in any of the articles.
12

Since IE doesn't support it (not even v8), I use jQuery.each() -- http://docs.jquery.com/Utilities/jQuery.each

answered Nov 30, 2009 at 23:42

4 Comments

v8 = version 8. V8 = Google V8.
For IE8 compatibility use: for(var i=0;i<array.length;i++) {} cycle instead.
The best option is to avoid Array.forEach indeed, since we know not all browsers support it
or define it by yourselves: smthngsmwhr.wordpress.com/2012/10/22/…
4

All modern browsers but IE.

answered Oct 1, 2008 at 8:34

1 Comment

So, that is: "All modern browsers."
1

The Microsoft AJAX client library adds this to the Array prototype so if you have that client library in your site then you'll have it for sure.

answered Oct 1, 2008 at 9:26

2 Comments

Does this change the Array implementation in IE? last time I checked, extending the Array object in IE failed.
I'd think so, I hardly think the MS AJAX team would make IE break :P
0

If you need all browsers to support this and other JavaScript 1.6 to 1.8 functions, I would suggest using the customizable jPaq library. The functions are implemented in the way that was suggested by Mozilla.

answered Mar 23, 2011 at 15:49

Comments

0

I have checked on caniuse.com and it looks like all browsers support foreach except Opera Mini which has support info as ?Support unknow. If you're interested you can use this link to check the browser support for any features. https://caniuse.com/?search=foreach

answered Dec 15, 2020 at 8:09

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.