<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>hello world</title> </head> <body> <script type="text/javascript"> var array=[1,2,3,4,5]; for(var i in array){ alert(array[i]);//数组的元素 } /*相当于:用for循环实现 for(var i=0;i<array.length;i++){ alert(array[i]);//数组的元素 }*/ </script> </body> </html>
时间: 2024-09-30 10:10:11