How to fix Array indexOf() in JavaScript for IE browsers?

Do it like this if (!Array.prototype. IndexOf) { } As recommended compatibility by MDC In general, browser detection code is a big no-no.

Do it like this... if (!Array.prototype. IndexOf) { } As recommended compatibility by MDC. In general, browser detection code is a big no-no.

I don't have enough rep to edit the question but feel free to remove the ECMAScript lingo and replace with the appropriate wording. Thanks Again – Bobby Borszich Nov 16 '09 at 19:47 3 Be careful if you use this kind of detection. Another library might implement this function before you test it, and it might not be standards compliant (prototype has done it a while ago).

If I were working in a hostile environment (lots of other coders using lots of distinct libraries), I wouldn't trust any of these... – Pablo Cabrera Nov 17 '09 at 11:38.

You should check if it's not defined using if (!Array.prototype. IndexOf). Also, your implementation of indexOf is not correct.

You must use === instead of == in your if (thisi == obj) statement, otherwise 4,"5". IndexOf(5) would be 1 according to your implementation, which is incorrect. I recommend you use the implementation on MDC.

Actually, it would be 1... – Pablo Cabrera Nov 17 '09 at 11:39.

Alternatively, you could use the jQuery. InArray function, which should work across browsers: api.jquery.com/jQuery.inArray.

Thanks for the answer . It works Great :) – naveen Jul 28 at 13:57.

Alternatively, you could use the jQuery 1.2 inArray function, which should work across browsers.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions