IE/JS: reduce on an object

不羁岁月 提交于 2019-12-22 04:45:12

问题


my javascript Application works on firefox and chrome very well. But it seams to be broken on Internet Explorer (IE 8).

I did not get an error Message on the console-log. By debugging the code I notice, that the application breaks on the following line:

 series.reduce(visit, []);

The whole function exits at this point. I know, that reduce works for arrays, but console.info(typeof(series)) tells: object

But this object exactly looks like an array - and it works on FF/Chrome. Could this be the reason, why IE stops processing the function at this point? And: how to handle this at IE?

Thank you.


回答1:


Reduce is not supported until IE 9 : https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/reduce#Browser_compatibility

That link does have a workaround bit of code for browsers that don't support reduce.




回答2:


You can also find other ES5 JavaScript array functions polyfills here:

http://tech.pro/tutorial/1834/working-with-es5-javascript-array-functions-in-modern-and-legacy-browsers#indexof



来源:https://stackoverflow.com/questions/7094935/ie-js-reduce-on-an-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!