标签:ack html vol 对象 new image array meta sof
1.for循环
循环代码块一定的次数
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> var cars=new Array() cars[0]="Saab" cars[1]="BMW" cars[2]="Volvo" for (var i = 0; i < cars.length; i++) { document.write(cars[i]+"<br />") } </script> </body> </html>
输出:
、
2.for/in循环
循环遍历对象的属性
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> var cars=new Array() cars[0]="Saab" cars[1]="BMW" cars[2]="Volvo" for (x in cars) { document.write(cars[x]+"<br />") } </script> </body> </html>
输出:
在此处两个循环输出效果一样
标签:ack html vol 对象 new image array meta sof
原文地址:https://www.cnblogs.com/-xiao/p/9800527.html