[thelist] Javascript array loop issues?

Christian Heilmann codepo8 at gmail.com
Thu Oct 29 13:07:53 CDT 2009


Jay Turley wrote:
> I think your problem may be that you are creating an object literal by  
> using the braces {} instead of the brackets [] to create your array  
> elements. Try it like this:
>
> var getErrors = [ errorName: errorMsg, ...];
>
> Jay
>
>
>   
No, a "associative array" is a misnomer as in JS it is an object. You 
cannot loop over the properties of an object using length, what you need 
to do is using a for...in loop.

http://stackoverflow.com/questions/921789/how-to-loop-through-javascript-object-literal-with-objects-as-members





More information about the thelist mailing list