This project has moved. For the latest updates, please go here.
1
Vote

Problem with foreach in Javascript routine

description

When I include the linq2indexeddb library into my proyect suddenly every for (var i in list) dont work fine, because when "i" takes the last value, in the next cycle "i" takes the value "contains" and I dont know why.

comments

KDegrave wrote Feb 7, 2014 at 6:55 AM

Hi,

Thank you for mentioning this. Is it possible to provide an example application so I can see what is going wrong exactly?

greetings,

Kristof

omar_e_rc wrote Feb 7, 2014 at 2:40 PM

I made a example that replicate the issue. You can download it in the next link (https://www.dropbox.com/s/r5fsxc60fo7ak61/Demo.zip).

KDegrave wrote Feb 9, 2014 at 7:18 AM

Hi,

I did some research, and you are right. I didn't know that my contains exstension had effect of the for in loop on an array. I have been looking for a solution, but didn't found one yet. But I found the following post on stackoverflow: http://stackoverflow.com/questions/500504/why-is-using-for-in-with-array-iteration-such-a-bad-ideal

Here they discuss why you shouldn't use the for in syntax on an array.

greetings,

Kristof