I have an associative array (object) of the following construction
var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D');
menu['Submenu A']=new Object();
menu['Submenu A']['Option A']= 'foo blah text';
menu['Submenu A']['Option B']= 'blah more text';
menu['Submenu B']['Option A']= 'blah blah';
menu['Submenu B']['Option B']= 'texty text';
...
etc.
This is iterated over a for..in loop which breaks when using prototype due to extending the class with methods like toJSON() and camelise()
I've attempted using Prototype's .each method however it errors out reporting that menu['Submenu A'] is undefined, it can't seem to locate the options that are defined under it.
What is the proper way to iterate over an associative array in prototype?
Further clarification (thanks for the answers so far). I'm slowly migrating a project over to using prototype, but it has large amounts of code that aren't prototype compatible yet. The code in question is in a library used by several other files. The code as is called by a function, initialize_menu and contains the code
for (var i=0; i < menu.length; i++) {
populate_sub_menu(menu[i])
}
The submenu function is structured like this
function populate_sub_menu(subMenu){
for (var option in menu[subMenu]) {
html+=menu[subMenu][option]+'html'+subMenu+option;
}
}
I'm leaving out code regarding getting html elements and such that aren't related to the problem.