R. Bemrose ([info]powerlord) wrote,
@ 2009-05-22 12:32:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
jQuery fun fact: Blowing up Javascript's for... in
I found out something interesting today. If you have jQuery loaded, it overloads the javascript Array type object to add a method remove().

Of course, Javascript is so smart that it includes remove when you do this:
for (var i in jsArray) {
    // Runs once for each element
    // ...plus one if jQuery is loaded
}


Whoops. Unfortunately, this means that I now have to double my logic, because while for.. in still works fine for Objects while jQuery is loaded, I need a for loop for Arrays.



Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…