Mega Code Archive

 
Categories / JavaScript Tutorial / Statement
 

Use while loop to output all elements in an array

< html> <head> <title>Use while loop to output all elements in an array</title> </head> <body> <h1>Use while loop to output all elements in an array</h1> <script language="javascript" type="text/javascript"> <!-- var ages = new Array(12,57,32,6,21,19); var i=0; while (ages.length) {   var tempAge = ages.pop();   document.write("<P>" + tempAge + "</p>"); } //--> </script> </body> </html>