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?
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.
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.
由于IE不支持它(甚至没有V8),我使用jQuery.each() - http://docs.jquery.com/Utilities/jQuery.each
链接地址: http://www.djcxy.com/p/4202.html上一篇: 如何在jQuery中循环数组?