views:

655

answers:

4

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?

+1  A: 

All modern browsers but IE.

Sergey Ilinsky
+3  A: 

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.

PhiLho
A: 

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.

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

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

Joubert Nel