Y
Yereth Jansen
Hi all,
I encountered a problem with looping through an associative array. All
worked perfectly with the following code:
for (var menuItem in this.menuItems) {
doSomething();
}
where this.menuItems is an associative array. The problem occurred when
I added the following function to the Array prototype:
Array.prototype.print_r = function() {
print_the_array_code();
}
After adding this method, the for/in loop took print_r as an element as
well. So besides the items I actually wanted to get from my array, I
also go print_r, which obviously I don't want. Does anyone have a
suggestion what to do with this..?
Thanks in advance,
Yereth Jansen
I encountered a problem with looping through an associative array. All
worked perfectly with the following code:
for (var menuItem in this.menuItems) {
doSomething();
}
where this.menuItems is an associative array. The problem occurred when
I added the following function to the Array prototype:
Array.prototype.print_r = function() {
print_the_array_code();
}
After adding this method, the for/in loop took print_r as an element as
well. So besides the items I actually wanted to get from my array, I
also go print_r, which obviously I don't want. Does anyone have a
suggestion what to do with this..?
Thanks in advance,
Yereth Jansen