Mega Code Archive

 
Categories / JavaScript DHTML / Data Type
 

Use string as the index and use for loop to loop through it

<html>   <head>     <title>Array literal</title>     <script type="text/javascript" > var planets = []; planets['inner'] = ['A', 'B', 'C']; planets['outer'] = ['a', 'b', 'c']; for (var i in planets) {   document.write(planets[i]);   document.write("<BR>"); }     </script>   </head>   <body>   </body> </html>