Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array.prototype.indexOf causes for..in on Array to have extra element in IE #28

Open
zajax opened this issue Jun 24, 2011 · 3 comments
Open

Comments

@zajax
Copy link

zajax commented Jun 24, 2011

I came across this the other day. Another developer was using for...in to loop through an Array. In IE, it would include the indexOf function as an item in the area. Very odd, but a pain to figure out.

Recreate:
Include stylish select.

In another javascript file, after stylish select has been run, execute this code:

var arr = [1,2,3];

for(var i in arr){
alert(arr[i]);
alert(typeof(arr[i]));
}

Question: Do you need to add indexOf to the prototype, or could you just use the $.inArrray()? http://api.jquery.com/jQuery.inArray/

@ifiokjr
Copy link

ifiokjr commented Dec 16, 2014

Any updates on this. I can submit a fix?

Or is this project pretty dead?

@scottdarby
Copy link
Owner

Not touched the project for a while, but you're welcome to submit a pr if
you like.

On 16 December 2014 at 17:06, Ifiok Jr. [email protected] wrote:

Any updates on this. I can submit a fix?

Or is this project pretty dead?

Reply to this email directly or view it on GitHub
#28 (comment)
.

@simonhamp
Copy link

Also it's worth noting that that the indexOf prototype override in this plugin can dramatically affect other code. I had a problem today when some third-party JS (a widget) was relying on indexOf returning -1 when it can't find a given element in the array - the expected response.

However, this module (crazily) returns undefined, completely borking the expected behaviour and resulting in broken widgets everywhere. Discontinued!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants