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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to