IE / JS:减少对象

时间:2022-11-11 22:07:43

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

我的javascript应用程序非常适用于firefox和chrome。但它的接缝在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

此时整个功能退出。我知道,reduce适用于数组,但是console.info(typeof(series))告诉: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?

但是这个对象看起来就像一个数组 - 它适用于FF / Chrome。这可能是为什么IE此时停止处理功能的原因?并且:如何在IE处理这个?

Thank you.

谢谢。

2 个解决方案

#1


17  

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

IE 9之前不支持Reduce: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.

对于不支持reduce的浏览器,该链接确实有一些代码解决方法。

#2


3  

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

您还可以在此处找到其他ES5 JavaScript数组函数polyfill:

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

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

#1


17  

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

IE 9之前不支持Reduce: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.

对于不支持reduce的浏览器,该链接确实有一些代码解决方法。

#2


3  

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

您还可以在此处找到其他ES5 JavaScript数组函数polyfill:

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

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