"Andreas Neumann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > but what alternative do I have to the "for .. in" loop. How can I step through > all elements of an associative array withouth using "for .. in"
No, you can do it, just make sure that the type of the thing you get back is the object you expect and not a function - that's real belt and braces stuff really, if you don't prototype array, you're probably okay, and the failure cases should be rare. Alternatively you can do: function Chicken() {} a=new Chicken() a['moo']=whatever This will allow you to avoid the prototype risk of array (people are very unlikely to prototype object directly), at the loss of any array like features. > Or should I avoid using associative arrays at all? Would be bad news. I am quite > used to associative arrays, coming from perl/PHP They're okay, as long as you don't expect them to be ordered (use a real array for that) and don't prototype anything on the array/object. what you can do is: a=[] a['chicken']=whatever a.push(a['chicken']) for (i=0;i<a.length;i++) alert(a) Which allows you iterate over them in order by using the array features, and still get the associative array features. Jim. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]