javascript学习指南_JavaScript Break and Continue 语法及实例教程

时间:2015-08-17  来源:报表/图形  阅读:

JavaScript Break and Continue 语法及实例教程,下面我们来看看教程吧.

有两个特殊的报表,可用于内部循环:break loop。

范例
break语句
使用break语句打破循环。



<script type="text/javascript">
var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
  {
  break;
  }
document.write("The number is " + i);
document.write("
");
}
</script>

Explanation: The loop will break when i=3.



Continue statement
继续使用声明,打破目前的循环,并继续在未来的价值。



<script type="text/javascript">
var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
  {
  continue;
  }
document.write("The number is " + i);
document.write("
");
}
</script>

Explanation: The loop will break the current loop and continue with the next value when i=3.



输出结果.

The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10


Explanation: The loop will break the current loop and continue with the next value when i=3.

好了下面再看.

JavaScript的突破,并继续发言
有两个特殊的报表,可用于内部循环:打破并继续。

Break
休息的命令将打破循环,并继续执行下面的代码后,环(如有的话) 。

例如



<script type="text/javascript">
var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
{
break;
}
document.write("The number is " + i);
document.write("
");
}
</script>


输出为.
The number is 0
The number is 1
The number is 2

 

javascript学习指南_JavaScript Break and Continue 语法及实例教程

http://m.bbyears.com/asp/17362.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新