The problem is in my case, I'm adding elements to the array as I go, as opposed to building it as a JSON-type hash up front.
I'd like to be able to do: ax[newValue] = y Looping through an associative array should be simple, but I'm missing something here. On Apr 2, 10:38 am, Walter Lee Davis <[email protected]> wrote: > I wasn't aware that JavaScript arrays could be associative like this. > My understanding was that they are always numerically indexed, and if > you want an associative "array-like structure" that you can iterate > over, you should use a vanilla Object or a Prototype Hash. > > var ax = {'aaa':1,'aab':2,'aac':4,'aad',6} > > for(i in ax){ > alert( i + ': ' + ax[i] ); > > } > > var ax = $H({'aaa':1,'aab':2,'aac':4,'aad',6}); > > ax.each(function(s){ alert( s ) }); > > Walter > > On Apr 2, 2009, at 10:28 AM, Diodeus wrote: > > > 'm building the following array: > > > var ax = [] > > ax['aaa'] = 1 > > ax['aab'] = 2 > > ax['aac'] = 4 > > ax['aad'] = 6 > > > I would like to loop though all of the values in this array. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
