:::: MENU ::::

Object doesn’t support property or method ‘indexOf’ in IE 8 – Fix

This error usually comes, if you tested your code in all modern browsers but missed in earlier version of IE. As Internet Explore <= 8 doesn’t support some latest features of javascript which are specified in ECMAScript 5.0.

JavaScript indexof() Method

This function finds the position of given element from “string” or “array”, depends on the situation. Internet Explore 6,7,8 don’t support indexOf() method on Array while it works fine on Strings.  So, in case you have used this method for some complex array manipulation for modern browser app, it might possible you get complaint from QA team, that your javascript doesn’t works in IE8.

Implementing Array.indexOf in Internet Explore 8 (polyfill)

You could use above polyfill function to make it work in all incompatible browsers.

Use jQuery index function for Array.indexOf method

You could even use jQuery indexOf function to fix this error in incompatible browsers.

Try out adhoc function (indexOf1) implementation in this fiddle – http://jsfiddle.net/vikaskbh/vb9m7/

So, what do you think ?