`
youyu4
  • 浏览: 424877 次
社区版块
存档分类
最新评论

For/In 循环、do/while 循环

 
阅读更多

 

JavaScript for/in 语句循环遍历对象的属性:

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

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

 

 

下面do/while 循环

该循环至少会执行一次,即使条件是 false,隐藏代码块会在条件被测试前执行:

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

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics