<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>for-in语句</title> </head> <body> <script type="text/javascript"> var arr = ['ab',34,true,false,3.14]; //使用for-in语句来遍历数组 for( x in arr ){ //x表示的是数组的索引 document.write(arr[x] + " "); } </script> </body> </html>