IE9 array does not support indexOf

a 夏天 提交于 2019-12-01 03:25:20

Are you sure your page is running in IE9 mode? Check in dev tools (F12). If you have old DOCTYPE you might be seeing your page in IE8/7 mode, so indexOf is not supported. If you are running in IE9 mode then it works just fine.

your code looks right and this compatibility table shows that IE9 should support indexOf() and checks your actual browser for compatibility.

try to open it and take a look at your result. maybe you're running you IE in compatibility mode for IE7/8 or something else.

this jsfiddle works in my IE9 - please try that, too.

It might help if you declare the array explicitly:

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