网站首页/硬件软件列表/内容

JavaScript图文详细教程之Break与Continue_javascript

硬件软件2022-05-27阅读
软件是一系列按照特定顺序组织的计算机数据和指令的集合。一般来讲软件被划分为编程语言、系统软件、应用软件和介于这两者之间的中间件。硬件是“计算机硬件”的简称。与“软件”相对,电子计算机系统中所有实体部件和设备的统称。

  JavaScript 有些功能是要区分的比如break 和 continue 语句,现在就给大家介绍下JavaScript break 和 continue 语句吧。

JavaScript教程之Break和Continue
JavaScript教程之Break和Continue

  有两种特殊的语句可用在循环内部:break 和 continue。

  Break

  break命令可以终止循环的运行,然后继续执行循环之后的代码(如果循环之后有代码的话)。

  实例:

  《html》

  《body》

  《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(“《br /》”)

  }

  《/script》

  《/body》

  《/html》

  结果:

  The number is 0

  The number is 1

  The number is 2

  Continue

  continue命令会终止当前的循环,然后从下一个值继续运行。

  实例:

  《html》

  《body》

  《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(“《br /》”)

  }

  《/script》

  《/body》

  《/html》


硬件是实在的,有模有样的。软件是程序性的。是一系列的指令。有了软件,硬件才会实现更丰富的功能。

……

相关阅读