码迷,mamicode.com
首页 > Web开发 > 详细

js 循环

时间:2018-08-10 21:19:17      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:console   number   bsp   for循环   while 循环   car   john   person   write   

1. for 循环

for (var i=0; i<5; i++)
  {
  console.log(‘hello‘);
  }

2. for in 循环

var person={fname:"John",lname:"Doe",age:25};

for (x in person)
  {
  txt=txt + person[x];
  }

3.  while 循环

while (i<5)
  {
  x=x + "The number is " + i + "<br>";
  i++;
  }

cars=["BMW","Volvo","Saab","Ford"];
var i=0;
for (;cars[i];)
{
document.write(cars[i] + "<br>");
i++;
}

4.  do/while 循环  

do
  {
  x=x + "The number is " + i + "<br>";
  i++;
  }
while (i<5);

1.for循环

1.for循环

1.for循环

1.for循环

js 循环

标签:console   number   bsp   for循环   while 循环   car   john   person   write   

原文地址:https://www.cnblogs.com/justSmile2/p/9456916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!