| R. Bemrose ( @ 2009-05-22 12:32:00 |
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:
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.
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.