1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 //将数组里面的元素挨个打印 10 var a1=['Q','s','c',1,4,9,'奥特曼','篮球']; 11 console.log(a1[0]); 12 console.log(a1[1]); 13 console.log(a1[2]); 14 15 //使用for循环打印 16 for(var i=0;i<a1.length;i++){ 17 console.log(a1[i]); 18 } 19 //使用while打印 20 var i=0; 21 while(i<a1.length){ 22 console.log(a1[i]); 23 i++ 24 } 25 </script> 26 </body> 27 </html>标签:遍历,console,log,元素,a1,数组,var From: https://www.cnblogs.com/webaction/p/16644879.html